update permission user & group lookup as suggested

This commit is contained in:
ryanmerolle 2021-04-26 09:17:25 -04:00
parent 474ca9e78f
commit 8678ad92ce

View File

@ -43,7 +43,7 @@ for permission_name, permission_details in object_permissions.items():
if permission_details.get("groups", 0): if permission_details.get("groups", 0):
for groupname in permission_details["groups"]: for groupname in permission_details["groups"]:
group = AdminGroup.objects.get(name=groupname) group = AdminGroup.objects.filter(name=groupname).first()
if group: if group:
object_permission.groups.add(group) object_permission.groups.add(group)
@ -51,7 +51,7 @@ for permission_name, permission_details in object_permissions.items():
if permission_details.get("users", 0): if permission_details.get("users", 0):
for username in permission_details["users"]: for username in permission_details["users"]:
user = AdminUser.objects.get(username=username) user = AdminUser.objects.filter(username=username).first()
if user: if user:
object_permission.users.add(user) object_permission.users.add(user)