mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
comment out community update code
This commit is contained in:
parent
59950aba5b
commit
c2a6b9d746
@ -11,65 +11,66 @@ from app.models import (
|
|||||||
from ..decorators import corpus_follower_permission_required
|
from ..decorators import corpus_follower_permission_required
|
||||||
from . import bp
|
from . import bp
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers', methods=['POST'])
|
|
||||||
@corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
# @bp.route('/<hashid:corpus_id>/followers', methods=['POST'])
|
||||||
@content_negotiation(consumes='application/json', produces='application/json')
|
# @corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
||||||
def create_corpus_followers(corpus_id):
|
# @content_negotiation(consumes='application/json', produces='application/json')
|
||||||
usernames = request.json
|
# def create_corpus_followers(corpus_id):
|
||||||
if not (isinstance(usernames, list) or all(isinstance(u, str) for u in usernames)):
|
# usernames = request.json
|
||||||
abort(400)
|
# if not (isinstance(usernames, list) or all(isinstance(u, str) for u in usernames)):
|
||||||
corpus = Corpus.query.get_or_404(corpus_id)
|
# abort(400)
|
||||||
for username in usernames:
|
# corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
user = User.query.filter_by(username=username, is_public=True).first_or_404()
|
# for username in usernames:
|
||||||
user.follow_corpus(corpus)
|
# user = User.query.filter_by(username=username, is_public=True).first_or_404()
|
||||||
db.session.commit()
|
# user.follow_corpus(corpus)
|
||||||
response_data = {
|
# db.session.commit()
|
||||||
'message': f'Users are now following "{corpus.title}"',
|
# response_data = {
|
||||||
'category': 'corpus'
|
# 'message': f'Users are now following "{corpus.title}"',
|
||||||
}
|
# 'category': 'corpus'
|
||||||
return response_data, 200
|
# }
|
||||||
|
# return response_data, 200
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>/role', methods=['PUT'])
|
# @bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>/role', methods=['PUT'])
|
||||||
@corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
# @corpus_follower_permission_required('MANAGE_FOLLOWERS')
|
||||||
@content_negotiation(consumes='application/json', produces='application/json')
|
# @content_negotiation(consumes='application/json', produces='application/json')
|
||||||
def update_corpus_follower_role(corpus_id, follower_id):
|
# def update_corpus_follower_role(corpus_id, follower_id):
|
||||||
role_name = request.json
|
# role_name = request.json
|
||||||
if not isinstance(role_name, str):
|
# if not isinstance(role_name, str):
|
||||||
abort(400)
|
# abort(400)
|
||||||
cfr = CorpusFollowerRole.query.filter_by(name=role_name).first()
|
# cfr = CorpusFollowerRole.query.filter_by(name=role_name).first()
|
||||||
if cfr is None:
|
# if cfr is None:
|
||||||
abort(400)
|
# abort(400)
|
||||||
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()
|
||||||
response_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'
|
||||||
}
|
# }
|
||||||
return response_data, 200
|
# return response_data, 200
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>', methods=['DELETE'])
|
# @bp.route('/<hashid:corpus_id>/followers/<hashid:follower_id>', methods=['DELETE'])
|
||||||
def delete_corpus_follower(corpus_id, follower_id):
|
# def delete_corpus_follower(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()
|
||||||
if not (
|
# if not (
|
||||||
current_user.id == follower_id
|
# current_user.id == follower_id
|
||||||
or current_user == cfa.corpus.user
|
# or current_user == cfa.corpus.user
|
||||||
or CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=current_user.id).first().role.has_permission('MANAGE_FOLLOWERS')
|
# or CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=current_user.id).first().role.has_permission('MANAGE_FOLLOWERS')
|
||||||
or current_user.is_administrator()):
|
# or current_user.is_administrator()):
|
||||||
abort(403)
|
# abort(403)
|
||||||
if current_user.id == follower_id:
|
# if current_user.id == follower_id:
|
||||||
flash(f'You are no longer following "{cfa.corpus.title}"', 'corpus')
|
# flash(f'You are no longer following "{cfa.corpus.title}"', 'corpus')
|
||||||
response = make_response()
|
# response = make_response()
|
||||||
response.status_code = 204
|
# response.status_code = 204
|
||||||
else:
|
# else:
|
||||||
response_data = {
|
# response_data = {
|
||||||
'message': f'"{cfa.follower.username}" is not following "{cfa.corpus.title}" anymore',
|
# 'message': f'"{cfa.follower.username}" is not following "{cfa.corpus.title}" anymore',
|
||||||
'category': 'corpus'
|
# 'category': 'corpus'
|
||||||
}
|
# }
|
||||||
response = jsonify(response_data)
|
# response = jsonify(response_data)
|
||||||
response.status_code = 200
|
# response.status_code = 200
|
||||||
cfa.follower.unfollow_corpus(cfa.corpus)
|
# cfa.follower.unfollow_corpus(cfa.corpus)
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
return response
|
# return response
|
||||||
|
@ -71,6 +71,7 @@ def corpus(corpus_id):
|
|||||||
users = users
|
users = users
|
||||||
)
|
)
|
||||||
if (current_user.is_following_corpus(corpus) or corpus.is_public):
|
if (current_user.is_following_corpus(corpus) or corpus.is_public):
|
||||||
|
abort(403)
|
||||||
cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all()
|
cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all()
|
||||||
print(cfas)
|
print(cfas)
|
||||||
return render_template(
|
return render_template(
|
||||||
@ -98,14 +99,14 @@ def analysis(corpus_id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/<hashid:corpus_id>/follow/<token>')
|
# @bp.route('/<hashid:corpus_id>/follow/<token>')
|
||||||
def follow_corpus(corpus_id, token):
|
# def follow_corpus(corpus_id, token):
|
||||||
corpus = Corpus.query.get_or_404(corpus_id)
|
# corpus = Corpus.query.get_or_404(corpus_id)
|
||||||
if current_user.follow_corpus_by_token(token):
|
# if current_user.follow_corpus_by_token(token):
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
flash(f'You are following "{corpus.title}" now', category='corpus')
|
# flash(f'You are following "{corpus.title}" now', category='corpus')
|
||||||
return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
# return redirect(url_for('corpora.corpus', corpus_id=corpus_id))
|
||||||
abort(403)
|
# abort(403)
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/import', methods=['GET', 'POST'])
|
@bp.route('/import', methods=['GET', 'POST'])
|
||||||
|
Loading…
Reference in New Issue
Block a user