diff --git a/cds/modules/invenio_deposit/api.py b/cds/modules/invenio_deposit/api.py index 82fafe42b..b4a1982a1 100644 --- a/cds/modules/invenio_deposit/api.py +++ b/cds/modules/invenio_deposit/api.py @@ -188,7 +188,7 @@ def merge_with_published(self): args = [lca.dumps(), first.dumps(), self.dumps()] for arg in args: del arg["$schema"], arg["_deposit"] - # pop optional removed key `current_user_mail` when present + # skip legacy `current_user_mail` when comparing for merging arg.get("_cds", {}).pop("current_user_mail", None) args.append({}) m = Merger(*args) @@ -196,6 +196,8 @@ def merge_with_published(self): m.run() except UnresolvedConflictsException: raise MergeConflict() + # remove legacy `current_user_mail` when merging + lca.get("_cds", {}).pop("current_user_mail", None) return patch(m.unified_patches, lca) @index diff --git a/cds/modules/records/serializers/schemas/project.py b/cds/modules/records/serializers/schemas/project.py index 06b13ccb1..9cabff3b8 100644 --- a/cds/modules/records/serializers/schemas/project.py +++ b/cds/modules/records/serializers/schemas/project.py @@ -19,7 +19,7 @@ """Project JSON schema.""" from invenio_jsonschemas import current_jsonschemas -from marshmallow import Schema, fields, post_load +from marshmallow import Schema, fields, pre_load, post_load from ....deposit.api import Project, deposit_video_resolver from .common import ( @@ -44,6 +44,12 @@ class _CDSSSchema(Schema): state = fields.Raw() modified_by = fields.Int() + @pre_load + def remove_legacy_fields(self, data, **kwargs): + """Remove legacy fields.""" + data.pop("current_user_mail", None) + return data + class ProjectDepositSchema(DepositSchema): """Project Deposit Schema.""" diff --git a/cds/modules/records/serializers/schemas/video.py b/cds/modules/records/serializers/schemas/video.py index 1a0597670..c83e2e83a 100644 --- a/cds/modules/records/serializers/schemas/video.py +++ b/cds/modules/records/serializers/schemas/video.py @@ -19,7 +19,7 @@ """Video JSON schema.""" from invenio_jsonschemas import current_jsonschemas -from marshmallow import Schema, fields, post_load +from marshmallow import Schema, fields, pre_load, post_load from ....deposit.api import Video from ..fields.datetime import DateString @@ -47,6 +47,12 @@ class _CDSSSchema(Schema): extracted_metadata = fields.Raw() modified_by = fields.Int() + @pre_load + def remove_legacy_fields(self, data, **kwargs): + """Remove legacy fields.""" + data.pop("current_user_mail", None) + return data + class VideoDepositSchema(DepositSchema): """Project Deposit Schema."""