Skip to content

Commit

Permalink
rollback generateroles to upgrade, skip updating existing roles
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujawa committed Dec 10, 2024
1 parent da78ba7 commit 43d0927
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,27 +292,20 @@ def handle(self, *args: Any, **options: Any) -> None:
print("Old incompatible roles pairs were deleted.")

roles_created = []
roles_updated = []
for default_role in default_roles_matrix:
role, created = Role.objects.update_or_create(
role, created = Role.objects.get_or_create(
subsystem=Role.HOPE,
name=default_role["name"],
defaults={"permissions": [permission.value for permission in default_role["permissions"]]},
)

if created:
roles_created.append(role.name)
else:
roles_updated.append(role.name)

if roles_created:
print(f"New roles were created: {', '.join(roles_created)}")
else:
print("No new roles were created.")
if roles_updated:
print(f"These roles were updated: {', '.join(roles_updated)}")
else:
print("No roles were updated")

incompatible_roles_created = []
for role_pair in default_incompatible_roles:
Expand Down
1 change: 1 addition & 0 deletions src/hct_mis_api/apps/core/management/commands/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Command(BaseCommand):
def handle(self, *args: Any, **options: Any) -> None:
call_command("migratealldb")
call_command("collectstatic", "--no-default-ignore", interactive=False)
call_command("generateroles")
from adminactions.perms import create_extra_permissions

create_extra_permissions()

0 comments on commit 43d0927

Please sign in to comment.