updated given linting feedback

This commit is contained in:
ryanmerolle 2021-04-20 18:05:47 -04:00
parent 5d4ecb7f9e
commit a7a5d13637
2 changed files with 15 additions and 13 deletions

View File

@ -8,11 +8,9 @@ if groups is None:
sys.exit() sys.exit()
for params in groups: for params in groups:
groupname=params['name'] groupname = params["name"]
group, created = AdminGroup.objects.get_or_create( group, created = AdminGroup.objects.get_or_create(name=groupname)
name=groupname
)
if created: if created:
print("👥 Created group", groupname) print("👥 Created group", groupname)

View File

@ -13,13 +13,13 @@ if object_permissions is None:
for params in object_permissions: for params in object_permissions:
object_permission, created = ObjectPermission.objects.get_or_create( object_permission, created = ObjectPermission.objects.get_or_create(
name=params['name'], name=params["name"],
description=params['description'], description=params["description"],
enabled=params['enabled'], enabled=params["enabled"],
actions=params['actions'] actions=params["actions"],
) )
# Need to try to pass a list of model_name and app_label for more than just the current all objects. # Need to try to pass a list of model_name and app_label for more than the current ALL
# object_types = ContentType.objects.filter(app_label__in=params.pop("object_types")) # object_types = ContentType.objects.filter(app_label__in=params.pop("object_types"))
# object_permission.object_types.set(ContentType.objects.filter(app_label__in=params.pop("object_types"))) # object_permission.object_types.set(ContentType.objects.filter(app_label__in=params.pop("object_types")))
object_permission.object_types.set(ContentType.objects.all()) object_permission.object_types.set(ContentType.objects.all())
@ -32,13 +32,17 @@ for params in object_permissions:
if group: if group:
object_permission.groups.add(group) object_permission.groups.add(group)
print(" 👥 Assigned group %s object permission of %s" % (groupname, object_permission.name)) print(
" 👥 Assigned group %s object permission of %s" % (groupname, object_permission.name)
)
for username in params.get("users", []): for username in params.get("users", []):
user = AdminUser.objects.get(username=username) user = AdminUser.objects.get(username=username)
if user: if user:
object_permission.users.add(user) object_permission.users.add(user)
print(" 👤 Assigned user %s object permission of %s" % (username, object_permission.name)) print(
" 👤 Assigned user %s object permission of %s" % (username, object_permission.name)
)
object_permission.save() object_permission.save()