From f1eb32d5e1bcfe8a9357313c94231ef64f138a7f Mon Sep 17 00:00:00 2001 From: anikachurilova Date: Mon, 24 Jul 2023 10:36:57 +0200 Subject: [PATCH] access: allow dump of parent.access.settings field * closes https://github.com/inveniosoftware/invenio-rdm-records/issues/1374 --- .../services/schemas/parent/__init__.py | 3 --- invenio_rdm_records/services/schemas/parent/access.py | 11 ++++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/invenio_rdm_records/services/schemas/parent/__init__.py b/invenio_rdm_records/services/schemas/parent/__init__.py index fbd77f49f..1f2daa36c 100644 --- a/invenio_rdm_records/services/schemas/parent/__init__.py +++ b/invenio_rdm_records/services/schemas/parent/__init__.py @@ -33,9 +33,6 @@ class RDMParentSchema(ParentSchema, FieldPermissionsMixin): """Record schema.""" field_dump_permissions = { - # omit the 'access' field from dumps, except for users with - # 'manage' permissions - "access": "manage", # omit 'review' from dumps except for users with curate permission "review": "review", } diff --git a/invenio_rdm_records/services/schemas/parent/access.py b/invenio_rdm_records/services/schemas/parent/access.py index 05fdd9d6f..02058b6da 100644 --- a/invenio_rdm_records/services/schemas/parent/access.py +++ b/invenio_rdm_records/services/schemas/parent/access.py @@ -16,6 +16,7 @@ from marshmallow import Schema, fields, validate from marshmallow_utils.fields import ISODateString, SanitizedUnicode, TZDateTime +from marshmallow_utils.permissions import FieldPermissionsMixin class GrantSubject(Schema): @@ -68,9 +69,17 @@ class AccessSettingsSchema(Schema): accept_conditions_text = fields.String() -class ParentAccessSchema(Schema): +class ParentAccessSchema(Schema, FieldPermissionsMixin): """Access schema.""" + field_dump_permissions = { + # omit fields from dumps except for users with 'manage' permissions + # allow only 'settings' + "grants": "manage", + "owned_by": "manage", + "links": "manage", + } + grants = fields.List(fields.Nested(Grant)) owned_by = fields.Nested(Agent) links = fields.List(fields.Nested(SecretLink))