Skip to content

Commit

Permalink
Find the team object a different way.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Sep 25, 2024
1 parent 218cc24 commit 68557ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions galaxy_ng/app/migrations/_dab_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def copy_roles_to_role_definitions(apps, schema_editor):


def migrate_role_assignments(apps, schema_editor):

print('MIGRATE ROLE ASSIGNMENTS ...')

UserRole = apps.get_model('core', 'UserRole')
GroupRole = apps.get_model('core', 'GroupRole')
Group = apps.get_model('auth', 'Group')
Expand All @@ -125,15 +128,15 @@ def migrate_role_assignments(apps, schema_editor):

# Migrate team/group role assignments
for group_role in GroupRole.objects.all():

rd = RoleDefinition.objects.filter(name=group_role.role.name).first()
if not rd:
continue

# FIXME - why?
if not hasattr(group_role.group, 'team'):
actor = Team.objects.filter(group=group_role.group).first()
if actor is None:
continue

actor = group_role.group.team
if not group_role.object_id:
RoleTeamAssignment.objects.create(role_definition=rd, team=actor)
else:
Expand Down

0 comments on commit 68557ef

Please sign in to comment.