Fix: split user / group objects error (#6302)

This commit is contained in:
shamoon 2024-04-06 13:51:50 -07:00 committed by GitHub
parent c4a9697e02
commit 957691c454
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,14 +103,18 @@ class DocumentMetadataOverrides:
overrides.owner_id = doc.owner.id if doc.owner else None overrides.owner_id = doc.owner.id if doc.owner else None
overrides.tag_ids = list(doc.tags.values_list("id", flat=True)) overrides.tag_ids = list(doc.tags.values_list("id", flat=True))
overrides.view_users = get_users_with_perms( overrides.view_users = list(
doc, get_users_with_perms(
only_with_perms_in=["view_document"], doc,
).values_list("id", flat=True) only_with_perms_in=["view_document"],
overrides.change_users = get_users_with_perms( ).values_list("id", flat=True),
doc, )
only_with_perms_in=["change_document"], overrides.change_users = list(
).values_list("id", flat=True) get_users_with_perms(
doc,
only_with_perms_in=["change_document"],
).values_list("id", flat=True),
)
overrides.custom_field_ids = list( overrides.custom_field_ids = list(
doc.custom_fields.values_list("id", flat=True), doc.custom_fields.values_list("id", flat=True),
) )
@ -120,10 +124,14 @@ class DocumentMetadataOverrides:
attach_perms=True, attach_perms=True,
) )
overrides.view_groups = [ overrides.view_groups = [
group.id for group, perms in groups_with_perms if "view_document" in perms group.id
for group in groups_with_perms
if "view_document" in groups_with_perms[group]
] ]
overrides.change_groups = [ overrides.change_groups = [
group.id for group, perms in groups_with_perms if "change_document" in perms group.id
for group in groups_with_perms
if "change_document" in groups_with_perms[group]
] ]
return overrides return overrides