mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-03 13:35:37 +00:00
Chore: Consolidate to a single way to set permission on an object (#14453)
* Chore: drop set_permissions_for_object in favor of the bulk helper The same grant rules were implemented twice, and only the bulk version validated every action before writing, so the single-object one could leave a partial change behind. * Chore: type the set-permissions dict Callers passed whatever they had, including querysets of User and Group objects that only worked because id__in accepts a subquery.
This commit is contained in:
1 parent
a74256cd2a
commit
e7d70497c2
6 files changed
+73
-149
No files matched your search
@@ -38,7 +38,8 @@ from documents.models import StoragePath
|
||||
from documents.models import Tag
|
||||
from documents.models import WorkflowTrigger
|
||||
from documents.parsers import ParseError
|
||||
from documents.permissions import set_permissions_for_object
|
||||
from documents.permissions import PermissionsSpec
|
||||
from documents.permissions import set_permissions_for_objects
|
||||
from documents.plugins.base import AlwaysRunPluginMixin
|
||||
from documents.plugins.base import ConsumeTaskPlugin
|
||||
from documents.plugins.base import NoCleanupPluginMixin
|
||||
@@ -948,7 +949,7 @@ class ConsumerPlugin(
|
||||
or self.metadata.change_users is not None
|
||||
or self.metadata.change_groups is not None
|
||||
):
|
||||
permissions = {
|
||||
permissions: PermissionsSpec = {
|
||||
"view": {
|
||||
"users": self.metadata.view_users or [],
|
||||
"groups": self.metadata.view_groups or [],
|
||||
@@ -958,7 +959,7 @@ class ConsumerPlugin(
|
||||
"groups": self.metadata.change_groups or [],
|
||||
},
|
||||
}
|
||||
set_permissions_for_object(permissions=permissions, object=document)
|
||||
set_permissions_for_objects(permissions, Document, [document.pk])
|
||||
|
||||
if self.metadata.custom_fields:
|
||||
for field in CustomField.objects.filter(
|
||||
|
||||
Reference in new issue
Block a user