Created
February 28, 2024 12:10
-
-
Save DylanVerstraete/e4eb3267c4fbb32bd6c4f099f48a6f27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for role in roles { | |
let postgres_pool = postgres_pool.clone(); | |
let new_role_id = controllers::roles::create( | |
postgres_pool.clone(), | |
ModifiableRole { | |
name: role.name.clone(), | |
}, | |
new_project_id, | |
) | |
.await?; | |
let permissions = | |
controllers::directory_permissions::get_all_for_role(postgres_pool.clone(), role.id) | |
.await?; | |
for permission in permissions { | |
// todo: get the path of the original directory of this permssion | |
// and attach this to the new directory (by path) | |
let _ = controllers::directory_permissions::create( | |
postgres_pool.clone(), | |
( | |
InsertableDirectoryPermissionDto { | |
// TODO: figure out how to get the directory_id for the new project | |
directory_id: permission.directory_id, | |
is_admin: permission.is_admin, | |
list: permission.list, | |
read: permission.read, | |
write: permission.write, | |
delete: permission.delete, | |
}, | |
new_role_id, | |
), | |
) | |
.await?; | |
} | |
} |
but these processes are seperate since copy is recursive
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the process is
(1) copy directories template to copy
(2) copy roles with attached permissions
and you do both in a single go then you know which directory id you need without a by-path lookup, or am I missing something?