diff --git a/CHANGES.rst b/CHANGES.rst index dd243641d67..5b64274c522 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -33,6 +33,7 @@ Improvements - Use the new token-based URLs instead of API keys for persistent ical links and replace the calendar link widgets in category, event, session and contribution views with the more modern ones used in dashboard (:issue:`4776`, :pr:`4801`) +- Add an option to export editables to JSON (:issue:`4767`, :pr:`4810`) Internal Changes ^^^^^^^^^^^^^^^^ diff --git a/indico/modules/events/editing/blueprint.py b/indico/modules/events/editing/blueprint.py index 61cc72611a4..bf32925036a 100644 --- a/indico/modules/events/editing/blueprint.py +++ b/indico/modules/events/editing/blueprint.py @@ -71,10 +71,10 @@ _bp.add_url_rule('/editing/api/service/disconnect', 'api_service_disconnect', service.RHDisconnectService, methods=('POST',)) _bp.add_url_rule('/editing/api/service/status', 'api_service_status', service.RHServiceStatus) -_bp.add_url_rule('/editing/api//editables/prepare-archive', +_bp.add_url_rule('/editing/api//editables/prepare-', 'api_prepare_editables_archive', editable_list.RHPrepareEditablesArchive, methods=('POST',)) -_bp.add_url_rule('/editing//editables/archive/.zip', 'download_archive', - editable_list.RHDownloadArchive) +_bp.add_url_rule('/editing//editables//.zip', + 'download_archive', editable_list.RHDownloadArchive) _bp.add_url_rule('/editing/api//editables/assign', 'api_assign_editor', editable_list.RHAssignEditor, methods=('POST',)) _bp.add_url_rule('/editing/api//editables/assign/me', 'api_assign_myself', diff --git a/indico/modules/events/editing/client/js/management/editable_type/EditableList.jsx b/indico/modules/events/editing/client/js/management/editable_type/EditableList.jsx index df0e731e6b1..cddd8a9b9a2 100644 --- a/indico/modules/events/editing/client/js/management/editable_type/EditableList.jsx +++ b/indico/modules/events/editing/client/js/management/editable_type/EditableList.jsx @@ -298,13 +298,16 @@ function EditableListDisplay({ } }; - const checkedEditablesRequest = async (urlFunc, data = {}) => { + const checkedEditablesRequest = async (urlFunc, data = {}, urlData = {}) => { let response; try { - response = await indicoAxios.post(urlFunc({event_id: eventId, type: editableType}), { - editables: checked, - ...data, - }); + response = await indicoAxios.post( + urlFunc({event_id: eventId, type: editableType, ...urlData}), + { + editables: checked, + ...data, + } + ); } catch (error) { handleAxiosError(error); return null; @@ -317,7 +320,15 @@ function EditableListDisplay({ const downloadAllFiles = async () => { setActiveRequest('download'); - const rv = await checkedEditablesRequest(editablesArchiveURL); + const rv = await checkedEditablesRequest(editablesArchiveURL, {}, {archive_type: 'archive'}); + if (rv) { + location.href = rv.downloadURL; + } + }; + + const exportJSON = async () => { + setActiveRequest('json'); + const rv = await checkedEditablesRequest(editablesArchiveURL, {}, {archive_type: 'json'}); if (rv) { location.href = rv.downloadURL; } @@ -400,12 +411,20 @@ function EditableListDisplay({ loading={activeRequest === 'unassign'} /> {' '} -