From b267259d45adc25ba545c2518545b33e40b1e113 Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Mon, 30 Dec 2024 14:15:54 +0530 Subject: [PATCH] Removed v1,v2,v3 support for bulk articles upload --- portality/view/api_v1.py | 2 +- portality/view/api_v2.py | 2 +- portality/view/api_v3.py | 14 ++------------ 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/portality/view/api_v1.py b/portality/view/api_v1.py index d230bb0be6..df5e504926 100644 --- a/portality/view/api_v1.py +++ b/portality/view/api_v1.py @@ -90,7 +90,7 @@ def delete_article(article_id): def bulk_article_create(): # Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664 # return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301) - return api_v3.bulk_article_create() + raise Api400Error(API_UNSUPPORTED_ERROR) @blueprint.route("/bulk/articles", methods=["DELETE"]) diff --git a/portality/view/api_v2.py b/portality/view/api_v2.py index 873e66c65c..d1ca2539c3 100644 --- a/portality/view/api_v2.py +++ b/portality/view/api_v2.py @@ -90,7 +90,7 @@ def delete_article(article_id): def bulk_article_create(): # Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664 # return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301) - return api_v3.bulk_article_create() + raise Api400Error(API_UNSUPPORTED_ERROR) @blueprint.route("/bulk/articles", methods=["DELETE"]) diff --git a/portality/view/api_v3.py b/portality/view/api_v3.py index f4266f3b79..2b0eafe549 100644 --- a/portality/view/api_v3.py +++ b/portality/view/api_v3.py @@ -22,6 +22,7 @@ ANALYTICS_CATEGORY = app.config.get('ANALYTICS_CATEGORY_API', 'API Hit') ANALYTICS_ACTIONS = app.config.get('ANALYTICS_ACTIONS_API', {}) +API_UNSUPPORTED_ERROR = "Version 3 is no longer supported." @blueprint.route('/') def api_root(): @@ -253,18 +254,7 @@ def _load_income_articles_json(request): swag_spec=ArticlesBulkApi.create_swag()) # must be applied after @api_key_(optional|required) decorators. They don't preserve func attributes. @plausible.pa_event(ANALYTICS_CATEGORY, action=ANALYTICS_ACTIONS.get('bulk_article_create', 'Bulk article create')) def bulk_article_create(): - data = _load_income_articles_json(request) - - # delegate to the API implementation - ids = ArticlesBulkApi.create(data, current_user._get_current_object()) - - # get all the locations for the ids - inl = [] - for id in ids: - inl.append((id, url_for("api_v3.retrieve_article", article_id=id))) - - # respond with a suitable Created response - return bulk_created(inl) + raise Api400Error(API_UNSUPPORTED_ERROR) @blueprint.route("/bulk/articles", methods=["DELETE"])