Skip to content

Commit

Permalink
Fix argument of type 'ProjectUserObjectPermission' is not iterable (#…
Browse files Browse the repository at this point in the history
…2682)

* fix argument of type 'ProjectUserObjectPermission' is not iterable

fix exception thrown when running migration

* rename symbol
  • Loading branch information
kelvin-muchiri authored Aug 26, 2024
1 parent a201c91 commit e5f79ec
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ def add_project_entitylist_perm(apps, schema_editor):
"""Assign `add_project_entitylist` permission to existing Owners, Managers"""
Project = apps.get_model("logger", "Project")
content_type = ContentType.objects.get_for_model(Project)
perm = "add_project_entitylist"
perm_codename = "add_project_entitylist"

with use_master:
_, created = Permission.objects.get_or_create(
codename=perm,
codename=perm_codename,
content_type=content_type,
defaults={
"name": "Can add entitylist to project",
},
)

if created:
print(f"Permission {perm} created because it does not exist")
print(f"Permission {perm_codename} created because it does not exist")

project_qs = Project.objects.filter(deleted_at__isnull=True)
eta = project_qs.count()
Expand All @@ -42,13 +42,13 @@ def add_project_entitylist_perm(apps, schema_editor):
permission__codename="add_project"
)

for perm in project_user_obj_perm_qs.iterator(chunk_size=100):
user = User.objects.get(id=perm.user_id)
assign_perm(perm, user, project)
for user_obj_perm in project_user_obj_perm_qs.iterator(chunk_size=100):
user = User.objects.get(id=user_obj_perm.user_id)
assign_perm(perm_codename, user, project)

for perm in project_group_obj_perm_qs.iterator(chunk_size=100):
group = Group.objects.get(id=perm.group_id)
assign_perm(perm, group, project)
for group_obj_perm in project_group_obj_perm_qs.iterator(chunk_size=100):
group = Group.objects.get(id=group_obj_perm.group_id)
assign_perm(perm_codename, group, project)

eta -= 1
print("eta", eta)
Expand Down

0 comments on commit e5f79ec

Please sign in to comment.