Skip to content

Commit

Permalink
links: add media files archive link
Browse files Browse the repository at this point in the history
* fix typo in permissions
* closes zenodo/rdm-project#219
  • Loading branch information
anikachurilova authored and zzacharo committed Sep 11, 2023
1 parent 2e363f3 commit 057e5b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions invenio_rdm_records/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,17 @@ class RDMRecordServiceConfig(RecordServiceConfig, ConfiguratorMixin):
when=archive_download_enabled,
),
),
"archive_media": ConditionalLink(
cond=is_record,
if_=RecordLink(
"{+api}/records/{id}/media-files-archive",
when=archive_download_enabled,
),
else_=RecordLink(
"{+api}/records/{id}/draft/media-files-archive",
when=archive_download_enabled,
),
),
"latest": RecordLink("{+api}/records/{id}/versions/latest", when=is_record),
"latest_html": RecordLink("{+ui}/records/{id}/latest", when=is_record),
"draft": RecordLink("{+api}/records/{id}/draft", when=is_record),
Expand Down Expand Up @@ -531,7 +542,7 @@ class RDMMediaFileRecordServiceConfig(FileServiceConfig, ConfiguratorMixin):
file_links_list = {
"self": RecordLink("{+api}/records/{id}/media-files"),
"archive": RecordLink(
"{+api}/records/{id}/media-files-archive", # TODO needed?
"{+api}/records/{id}/media-files-archive",
when=archive_download_enabled,
),
}
Expand Down Expand Up @@ -596,7 +607,7 @@ class RDMMediaFileDraftServiceConfig(FileServiceConfig, ConfiguratorMixin):
file_links_list = {
"self": RecordLink("{+api}/records/{id}/draft/media-files"),
"archive": RecordLink(
"{+api}/records/{id}/draft/media-files-archive", # TODO needed?
"{+api}/records/{id}/draft/media-files-archive",
when=archive_download_enabled,
),
}
Expand Down
2 changes: 1 addition & 1 deletion invenio_rdm_records/services/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class RDMRecordPermissionPolicy(RecordPermissionPolicy):
# it was simpler and less coupling to implement this as permission check
IfFileIsLocal(then_=can_read, else_=[SystemProcess()])
]
can_media_create__files = [Disable()]
can_media_create_files = [Disable()]
can_media_set_content_files = [Disable()]
can_media_commit_files = [Disable()]
can_media_update_files = [Disable()]
Expand Down
2 changes: 2 additions & 0 deletions tests/resources/test_serialized_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_draft_links(client, draft_json, minimal_record, headers):
"files": f"https://127.0.0.1:5000/api/records/{pid_value}/draft/files",
"media_files": f"https://127.0.0.1:5000/api/records/{pid_value}/draft/media-files",
"archive": f"https://127.0.0.1:5000/api/records/{pid_value}/draft/files-archive", # noqa
"archive_media": f"https://127.0.0.1:5000/api/records/{pid_value}/draft/media-files-archive", # noqa
"reserve_doi": f"https://127.0.0.1:5000/api/records/{pid_value}/draft/pids/doi", # noqa
"self_iiif_manifest": f"https://127.0.0.1:5000/api/iiif/draft:{pid_value}/manifest", # noqa
"self_iiif_sequence": f"https://127.0.0.1:5000/api/iiif/draft:{pid_value}/sequence/default", # noqa
Expand Down Expand Up @@ -97,6 +98,7 @@ def test_record_links(client, published_json, headers):
"files": f"https://127.0.0.1:5000/api/records/{pid_value}/files",
"media_files": f"https://127.0.0.1:5000/api/records/{pid_value}/media-files",
"archive": f"https://127.0.0.1:5000/api/records/{pid_value}/files-archive",
"archive_media": f"https://127.0.0.1:5000/api/records/{pid_value}/media-files-archive",
"parent": f"https://127.0.0.1:5000/api/records/{parent_pid_value}",
"parent_doi": f"https://127.0.0.1:5000/doi/{parent_doi_value}",
"parent_html": f"https://127.0.0.1:5000/records/{parent_pid_value}",
Expand Down

0 comments on commit 057e5b7

Please sign in to comment.