Skip to content

Commit

Permalink
Removed v1,v2,v3 support for bulk articles upload
Browse files Browse the repository at this point in the history
  • Loading branch information
RK206 committed Dec 30, 2024
1 parent dad974c commit b267259
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion portality/view/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion portality/view/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
14 changes: 2 additions & 12 deletions portality/view/api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit b267259

Please sign in to comment.