aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-02 06:03:34 +0300
committerFrederick Muriuki Muriithi2023-08-02 06:03:34 +0300
commit26e2ecbba62120ad7534a3eacd67b9c6bb31cfbe (patch)
tree2bf1528d688f4c278cad72b33a231180bfbcbde9 /scripts
parentaab6fb9a82c148a0f87949dee058b04c3830eccd (diff)
downloadgenenetwork3-26e2ecbba62120ad7534a3eacd67b9c6bb31cfbe.tar.gz
Assign `group-leader` role to the admin for automatic group.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/migrate_existing_data.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/scripts/migrate_existing_data.py b/scripts/migrate_existing_data.py
index 8fb9467..427dc34 100644
--- a/scripts/migrate_existing_data.py
+++ b/scripts/migrate_existing_data.py
@@ -17,6 +17,8 @@ from gn3 import db_utils as biodb
from gn3.auth import db as authdb
from gn3.auth.authentication.users import User
from gn3.auth.authorisation.groups.models import Group, save_group
+from gn3.auth.roles.models import (
+ revoke_user_role_by_name, assign_user_role_by_name)
from gn3.auth.authorisation.resources.models import (
Resource, ResourceCategory, __assign_resource_owner_role__)
@@ -86,6 +88,8 @@ def admin_group(conn: authdb.DbConnection, admin: User) -> Group:
})
cursor.execute("INSERT INTO group_users VALUES (?, ?)",
(str(new_group.group_id), str(admin.user_id)))
+ revoke_user_role_by_name(cursor, group_leader, "group-creator")
+ assign_user_role_by_name(cursor, group_leader, "group-leader")
return new_group
def __resource_category_by_key__(