Skip to content

Commit

Permalink
records: fixes skipped empty values in serializers
Browse files Browse the repository at this point in the history
Signed-off-by: pamfilos <[email protected]>
  • Loading branch information
pamfilos committed Dec 20, 2023
1 parent 4225c5d commit 5f2b9fd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cap/modules/deposit/serializers/schemas/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def remove_skip_values(self, data):
keys = ["can_review", "review", "x_cap_permission", "egroups"]

for key in keys:
if not data.get(key, ""):
if data.get(key, "") is None:
del data[key]

return data
Expand Down
4 changes: 2 additions & 2 deletions cap/modules/records/serializers/schemas/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def remove_skip_values(self, data):
keys = ["egroups"]

for key in keys:
if not data.get(key, ''):
if data.get(key, '') is None:
del data[key]

return data
Expand Down Expand Up @@ -246,7 +246,7 @@ def get_schema(self, obj):

def get_egroups(self, obj):
_egroups = obj.get("metadata", {}).get("_egroups", [])
if "deposit" not in obj or obj["deposit"].schema_egroups_enabled():
if "deposit" in obj and obj["deposit"].schema_egroups_enabled():
return _egroups
else:
return None
Expand Down
2 changes: 1 addition & 1 deletion cap/modules/records/serializers/schemas/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def remove_skip_values(self, data):
keys = ["can_review", "review", "egroups"]

for key in keys:
if not data.get(key, ''):
if data.get(key, '') is None:
del data[key]

return data
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_get_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def test_get_record_with_form_json_serializer(
},
'can_update': True,
'is_owner': True,
# 'can_review': False,
'can_review': False,
'created': rec.created.strftime('%Y-%m-%dT%H:%M:%S.%f+00:00'),
'updated': rec.updated.strftime('%Y-%m-%dT%H:%M:%S.%f+00:00'),
'created_by': {'email': example_user.email, 'profile': {}},
Expand Down

0 comments on commit 5f2b9fd

Please sign in to comment.