update object permission conditionals
This commit is contained in:
parent
a1e0c52825
commit
4e31218ce6
@ -10,24 +10,25 @@ if object_permissions is None:
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
for params in object_permissions:
|
for permission_name, permission_details in object_permissions.items():
|
||||||
|
|
||||||
object_permission, created = ObjectPermission.objects.get_or_create(
|
object_permission, created = ObjectPermission.objects.get_or_create(
|
||||||
name=params["name"],
|
name=permission_name,
|
||||||
description=params["description"],
|
description=permission_details["description"],
|
||||||
enabled=params["enabled"],
|
enabled=permission_details["enabled"],
|
||||||
actions=params["actions"],
|
actions=permission_details["actions"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Need to try to pass a list of model_name and app_label for more than the current ALL
|
# 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=permission_details["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=permission_details"object_types"]))
|
||||||
object_permission.object_types.set(ContentType.objects.all())
|
object_permission.object_types.set(ContentType.objects.all())
|
||||||
object_permission.save()
|
object_permission.save()
|
||||||
|
|
||||||
print("🔓 Created object permission", object_permission.name)
|
print("🔓 Created object permission", object_permission.name)
|
||||||
|
|
||||||
for groupname in params.get("groups", []):
|
if permission_details.get("groups", 0):
|
||||||
|
for groupname in permission_details["groups"]:
|
||||||
group = AdminGroup.objects.get(name=groupname)
|
group = AdminGroup.objects.get(name=groupname)
|
||||||
|
|
||||||
if group:
|
if group:
|
||||||
@ -36,7 +37,8 @@ for params in object_permissions:
|
|||||||
" 👥 Assigned group %s object permission of %s" % (groupname, object_permission.name)
|
" 👥 Assigned group %s object permission of %s" % (groupname, object_permission.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
for username in params.get("users", []):
|
if permission_details.get("users", 0):
|
||||||
|
for username in permission_details["users"]:
|
||||||
user = AdminUser.objects.get(username=username)
|
user = AdminUser.objects.get(username=username)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
|
Loading…
Reference in New Issue
Block a user