mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05: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 = User.query.get_or_404(user_id)
|
||||||
user.confirmed = confirmed
|
user.confirmed = confirmed
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
resonse_data = {
|
response_data = {
|
||||||
'message': (
|
'message': (
|
||||||
f'User "{user.username}" is now '
|
f'User "{user.username}" is now '
|
||||||
f'{"confirmed" if confirmed else "unconfirmed"}'
|
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)
|
args=(current_app._get_current_object(), snpm.id)
|
||||||
)
|
)
|
||||||
thread.start()
|
thread.start()
|
||||||
resonse_data = {
|
response_data = {
|
||||||
'message': \
|
'message': \
|
||||||
f'SpaCy NLP Pipeline Model "{snpm.title}" marked for deletion'
|
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'])
|
@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 threading import Thread
|
||||||
from app import db
|
from app import db
|
||||||
from app.decorators import content_negotiation
|
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',
|
'message': f'Corpus File "{corpus_file.title}" marked for deletion',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 202
|
||||||
response.status_code = 202
|
|
||||||
return response
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from flask import abort, jsonify, request
|
from flask import abort, request
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from app import db
|
from app import db
|
||||||
from app.decorators import content_negotiation
|
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 = User.query.filter_by(username=username, is_public=True).first_or_404()
|
||||||
user.follow_corpus(corpus)
|
user.follow_corpus(corpus)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
resonse_data = {
|
response_data = {
|
||||||
'message': f'Users are now following "{corpus.title}"',
|
'message': f'Users are now following "{corpus.title}"',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(resonse_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>/role', methods=['PUT'])
|
@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 = CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=follower_id).first_or_404()
|
||||||
cfa.role = cfr
|
cfa.role = cfr
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
resonse_data = {
|
response_data = {
|
||||||
'message': f'User "{cfa.follower.username}" is now {cfa.role.name}',
|
'message': f'User "{cfa.follower.username}" is now {cfa.role.name}',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(resonse_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>', methods=['DELETE'])
|
@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',
|
f'"{follower.username}" is not following "{corpus.title}" anymore',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import (
|
from flask import abort, current_app, request, url_for
|
||||||
abort,
|
|
||||||
current_app,
|
|
||||||
jsonify,
|
|
||||||
request,
|
|
||||||
url_for
|
|
||||||
)
|
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from .decorators import corpus_follower_permission_required, corpus_owner_or_admin_required
|
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',
|
'message': f'Corpus "{corpus.title}" marked for deletion',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/build', methods=['POST'])
|
@bp.route('/<hashid:corpus_id>/build', methods=['POST'])
|
||||||
@ -50,7 +42,6 @@ def build_corpus(corpus_id):
|
|||||||
corpus.build()
|
corpus.build()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
print(corpus_id)
|
|
||||||
corpus = Corpus.query.get_or_404(corpus_id)
|
corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
if len(corpus.files.all()) == 0:
|
if len(corpus.files.all()) == 0:
|
||||||
abort(409)
|
abort(409)
|
||||||
@ -63,9 +54,7 @@ def build_corpus(corpus_id):
|
|||||||
'message': f'Corpus "{corpus.title}" marked for building',
|
'message': f'Corpus "{corpus.title}" marked for building',
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 202
|
||||||
response.status_code = 202
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/generate-share-link', methods=['POST'])
|
@bp.route('/<hashid:corpus_id>/generate-share-link', methods=['POST'])
|
||||||
@ -98,9 +87,7 @@ def generate_corpus_share_link(corpus_id):
|
|||||||
'category': 'corpus',
|
'category': 'corpus',
|
||||||
'corpusShareLink': corpus_share_link
|
'corpusShareLink': corpus_share_link
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +108,4 @@ def update_corpus_is_public(corpus_id):
|
|||||||
),
|
),
|
||||||
'category': 'corpus'
|
'category': 'corpus'
|
||||||
}
|
}
|
||||||
response = jsonify(response_data)
|
return response_data, 200
|
||||||
response.status_code = 200
|
|
||||||
return response
|
|
||||||
|
Loading…
Reference in New Issue
Block a user