Merge pull request #2818 from paperless-ngx/fix-2809

Fix: permissions display should not show users with inherited permissions & unable to change owner
This commit is contained in:
shamoon
2023-03-30 19:49:12 -07:00
committed by GitHub
10 changed files with 77 additions and 26 deletions

View File

@@ -63,6 +63,7 @@ def set_permissions_for_object(permissions, object):
users_to_remove = get_users_with_perms(
object,
only_with_perms_in=[permission],
with_group_users=False,
)
if len(users_to_add) > 0 and len(users_to_remove) > 0:
users_to_remove = users_to_remove.difference(users_to_add)

View File

@@ -162,6 +162,7 @@ class OwnedObjectSerializer(serializers.ModelSerializer, SetPermissionsMixin):
"users": get_users_with_perms(
obj,
only_with_perms_in=[view_codename],
with_group_users=False,
).values_list("id", flat=True),
"groups": get_groups_with_only_permission(
obj,
@@ -172,6 +173,7 @@ class OwnedObjectSerializer(serializers.ModelSerializer, SetPermissionsMixin):
"users": get_users_with_perms(
obj,
only_with_perms_in=[change_codename],
with_group_users=False,
).values_list("id", flat=True),
"groups": get_groups_with_only_permission(
obj,

View File

@@ -964,6 +964,7 @@ class UiSettingsView(GenericAPIView):
"id": user.id,
"username": user.username,
"is_superuser": user.is_superuser,
"groups": user.groups.values_list("id", flat=True),
},
"settings": ui_settings,
"permissions": roles,