Skip to content

Commit 446e1f7

Browse files
Update '_access.update' to include existing values
1 parent 0b25957 commit 446e1f7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cds/modules/deposit/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,13 @@ def create(cls, data, id_=None, **kwargs):
500500
kwargs.setdefault("bucket_location", "videos")
501501
data["$schema"] = current_jsonschemas.path_to_url(cls._schema)
502502
data.setdefault("videos", [])
503-
data.setdefault("_access", {})
504503
data.setdefault("_cds", {})
505-
# Add the current user to the ``_access.update`` list
504+
data.setdefault("_access", {})
505+
access_update = data["_access"].setdefault("update", [])
506506
try:
507-
data["_access"]["update"] = [current_user.email]
507+
if current_user.email not in access_update:
508+
# Add the current user to the ``_access.update`` list
509+
access_update.append(current_user.email)
508510
except AttributeError:
509511
current_app.logger.warning(
510512
"No current user found, _access.update will stay empty."

tests/unit/test_project_rest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def assert_bucket_for_video(bucket_id, video):
100100
assert res.status_code == 201
101101
project_dict = json.loads(res.data.decode("utf-8"))
102102
assert project_dict["metadata"]["videos"] == []
103+
assert User.query.get(users[0]).email in project_dict["metadata"]["_access"]["update"]
103104
assert project_dict["metadata"]["title"]["title"] == "my project"
104105
assert project_dict["links"]["bucket"].startswith("http://localhost/files/")
105106
assert all(

0 commit comments

Comments
 (0)