Upsert global default roles. Existing roles are updated in place to preserve FK references from userorganization.
(db_session: AsyncSession)
| 19 | |
| 20 | # Install Default roles |
| 21 | async def install_default_elements(db_session: AsyncSession): |
| 22 | """Upsert global default roles. Existing roles are updated in place to |
| 23 | preserve FK references from userorganization.""" |
| 24 | |
| 25 | logger = logging.getLogger(__name__) |
| 26 | |
| 27 | # Build the desired role definitions |
| 28 | role_global_admin = Role( |
| 29 | name="Admin", |
| 30 | description="Full platform control", |
| 31 | id=1, |
| 32 | role_type=RoleTypeEnum.TYPE_GLOBAL, |
| 33 | role_uuid="role_global_admin", |
| 34 | rights=Rights( |
| 35 | courses=PermissionsWithOwn( |
| 36 | action_create=True, |
| 37 | action_read=True, |
| 38 | action_read_own=True, |
| 39 | action_update=True, |
| 40 | action_update_own=True, |
| 41 | action_delete=True, |
| 42 | action_delete_own=True, |
| 43 | ), |
| 44 | users=Permission( |
| 45 | action_create=True, |
| 46 | action_read=True, |
| 47 | action_update=True, |
| 48 | action_delete=True, |
| 49 | ), |
| 50 | usergroups=Permission( |
| 51 | action_create=True, |
| 52 | action_read=True, |
| 53 | action_update=True, |
| 54 | action_delete=True, |
| 55 | ), |
| 56 | collections=Permission( |
| 57 | action_create=True, |
| 58 | action_read=True, |
| 59 | action_update=True, |
| 60 | action_delete=True, |
| 61 | ), |
| 62 | organizations=Permission( |
| 63 | action_create=True, |
| 64 | action_read=True, |
| 65 | action_update=True, |
| 66 | action_delete=True, |
| 67 | ), |
| 68 | coursechapters=Permission( |
| 69 | action_create=True, |
| 70 | action_read=True, |
| 71 | action_update=True, |
| 72 | action_delete=True, |
| 73 | ), |
| 74 | activities=Permission( |
| 75 | action_create=True, |
| 76 | action_read=True, |
| 77 | action_update=True, |
| 78 | action_delete=True, |