Merge pull request #148 from LBegnaud/master

adjusts users and groups startup scripts to accomdate non-uniqueness
This commit is contained in:
Christian Mäder 2019-07-30 10:44:03 +02:00 committed by GitHub
commit b0287e344e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -29,6 +29,6 @@ with file.open('r') as stream:
if user_permissions: if user_permissions:
user.user_permissions.clear() user.user_permissions.clear()
for permission_codename in user_details.get('permissions', []): for permission_codename in user_details.get('permissions', []):
permission = Permission.objects.get(codename=permission_codename) for permission in Permission.objects.filter(codename=permission_codename):
user.user_permissions.add(permission) user.user_permissions.add(permission)
user.save() user.save()

View File

@ -29,5 +29,5 @@ with file.open('r') as stream:
group.permissions.clear() group.permissions.clear()
print("Permissions:", group.permissions.all()) print("Permissions:", group.permissions.all())
for permission_codename in group_details.get('permissions', []): for permission_codename in group_details.get('permissions', []):
permission = Permission.objects.get(codename=permission_codename) for permission in Permission.objects.filter(codename=permission_codename):
group.permissions.add(permission) group.permissions.add(permission)