mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-14 16:55:42 +00:00
Fix typos and simplification
This commit is contained in:
parent
2fd7e35b99
commit
4ca2c0c873
@ -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
|
||||
|
@ -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/<hashid:spacy_nlp_pipeline_model_id>/is_public', methods=['PUT'])
|
||||
|
@ -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
|
||||
|
@ -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('/<hashid:corpus_id>/followers/<hashid:follower_id>/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('/<hashid:corpus_id>/followers/<hashid:follower_id>', 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
|
||||
|
@ -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('/<hashid:corpus_id>/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('/<hashid:corpus_id>/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
|
||||
|
Loading…
Reference in New Issue
Block a user