diff --git a/app/admin/json_routes.py b/app/admin/json_routes.py index d4c21307..9b4ca7d0 100644 --- a/app/admin/json_routes.py +++ b/app/admin/json_routes.py @@ -14,10 +14,10 @@ def update_user_role(user_id): user = User.query.get_or_404(user_id) user.confirmed = confirmed db.session.commit() - resonse_data = { + response_data = { 'message': ( f'User "{user.username}" is now ' f'{"confirmed" if confirmed else "unconfirmed"}' ) } - return resonse_data, 200 + return response_data, 200 diff --git a/app/contributions/spacy_nlp_pipeline_models/json_routes.py b/app/contributions/spacy_nlp_pipeline_models/json_routes.py index 073eaa5e..8c081ce8 100644 --- a/app/contributions/spacy_nlp_pipeline_models/json_routes.py +++ b/app/contributions/spacy_nlp_pipeline_models/json_routes.py @@ -24,11 +24,11 @@ def delete_spacy_model(spacy_nlp_pipeline_model_id): args=(current_app._get_current_object(), snpm.id) ) thread.start() - resonse_data = { + response_data = { 'message': \ f'SpaCy NLP Pipeline Model "{snpm.title}" marked for deletion' } - return resonse_data, 202 + return response_data, 202 @bp.route('/spacy-nlp-pipeline-models//is_public', methods=['PUT']) diff --git a/app/corpora/files/json_routes.py b/app/corpora/files/json_routes.py index faa5f233..1794c4d1 100644 --- a/app/corpora/files/json_routes.py +++ b/app/corpora/files/json_routes.py @@ -1,4 +1,4 @@ -from flask import current_app, jsonify +from flask import current_app from threading import Thread from app import db from app.decorators import content_negotiation @@ -27,6 +27,4 @@ def delete_corpus_file(corpus_id, corpus_file_id): 'message': f'Corpus File "{corpus_file.title}" marked for deletion', 'category': 'corpus' } - response = jsonify(response_data) - response.status_code = 202 - return response + return response_data, 202 diff --git a/app/corpora/followers/json_routes.py b/app/corpora/followers/json_routes.py index 7c16a838..b5c3c990 100644 --- a/app/corpora/followers/json_routes.py +++ b/app/corpora/followers/json_routes.py @@ -1,4 +1,4 @@ -from flask import abort, jsonify, request +from flask import abort, request from flask_login import current_user from app import db from app.decorators import content_negotiation @@ -24,13 +24,11 @@ def create_corpus_followers(corpus_id): user = User.query.filter_by(username=username, is_public=True).first_or_404() user.follow_corpus(corpus) db.session.commit() - resonse_data = { + response_data = { 'message': f'Users are now following "{corpus.title}"', 'category': 'corpus' } - response = jsonify(resonse_data) - response.status_code = 200 - return response + return response_data, 200 @bp.route('//followers//role', methods=['PUT']) @@ -46,13 +44,11 @@ def update_corpus_follower_role(corpus_id, follower_id): cfa = CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=follower_id).first_or_404() cfa.role = cfr db.session.commit() - resonse_data = { + response_data = { 'message': f'User "{cfa.follower.username}" is now {cfa.role.name}', 'category': 'corpus' } - response = jsonify(resonse_data) - response.status_code = 200 - return response + return response_data, 200 @bp.route('//followers/', methods=['DELETE']) @@ -71,6 +67,4 @@ def delete_corpus_follower(corpus_id, follower_id): f'"{follower.username}" is not following "{corpus.title}" anymore', 'category': 'corpus' } - response = jsonify(response_data) - response.status_code = 200 - return response + return response_data, 200 diff --git a/app/corpora/json_routes.py b/app/corpora/json_routes.py index e8142cf5..4da60341 100644 --- a/app/corpora/json_routes.py +++ b/app/corpora/json_routes.py @@ -1,11 +1,5 @@ from datetime import datetime -from flask import ( - abort, - current_app, - jsonify, - request, - url_for -) +from flask import abort, current_app, request, url_for from flask_login import current_user from threading import Thread from .decorators import corpus_follower_permission_required, corpus_owner_or_admin_required @@ -35,9 +29,7 @@ def delete_corpus(corpus_id): 'message': f'Corpus "{corpus.title}" marked for deletion', 'category': 'corpus' } - response = jsonify(response_data) - response.status_code = 200 - return response + return response_data, 200 @bp.route('//build', methods=['POST']) @@ -50,7 +42,6 @@ def build_corpus(corpus_id): corpus.build() db.session.commit() - print(corpus_id) corpus = Corpus.query.get_or_404(corpus_id) if len(corpus.files.all()) == 0: abort(409) @@ -63,9 +54,7 @@ def build_corpus(corpus_id): 'message': f'Corpus "{corpus.title}" marked for building', 'category': 'corpus' } - response = jsonify(response_data) - response.status_code = 202 - return response + return response_data, 202 @bp.route('//generate-share-link', methods=['POST']) @@ -98,9 +87,7 @@ def generate_corpus_share_link(corpus_id): 'category': 'corpus', 'corpusShareLink': corpus_share_link } - response = jsonify(response_data) - response.status_code = 200 - return response + return response_data, 200 @@ -121,6 +108,4 @@ def update_corpus_is_public(corpus_id): ), 'category': 'corpus' } - response = jsonify(response_data) - response.status_code = 200 - return response + return response_data, 200