diff --git a/app/corpora/routes.py b/app/corpora/routes.py index 274eebfb..5d1b1a41 100644 --- a/app/corpora/routes.py +++ b/app/corpora/routes.py @@ -15,7 +15,7 @@ from flask_login import current_user, login_required from threading import Thread import os from .decorators import corpus_follower_permission_required, corpus_owner_or_admin_required -from app import db +from app import db, hashids from app.models import ( Corpus, CorpusFile, @@ -67,6 +67,7 @@ def add_corpus_followers(corpus_id): @bp.route('//follow/') @login_required def follow_corpus(corpus_id, token): + corpus = Corpus.query.get_or_404(corpus_id) if current_user.follow_corpus_by_token(token): db.session.commit() flash(f'You are following {corpus.title} now', category='corpus') @@ -89,20 +90,8 @@ def unfollow_corpus(corpus_id, follower_id): return '', 204 -@bp.route('//unfollow', methods=['POST']) -@login_required -def current_user_unfollow_corpus(corpus_id): - corpus = Corpus.query.get_or_404(corpus_id) - if not current_user.is_following_corpus(corpus): - abort(409) # 'You are not following the corpus' - current_user.unfollow_corpus(corpus) - db.session.commit() - flash(f'You are not following {corpus.title} anymore', category='corpus') - return '', 204 - - @bp.route('//followers//role', methods=['POST']) -@corpus_follower_permission_required('REMOVE_FOLLOWER', 'UPDATE_FOLLOWER') +@corpus_follower_permission_required('UPDATE_FOLLOWER') def add_permission(corpus_id, follower_id): corpus_follower_association = CorpusFollowerAssociation.query.filter_by(corpus_id=corpus_id, follower_id=follower_id).first_or_404() if not (corpus_follower_association.corpus.user == current_user or current_user.is_administrator()): @@ -187,11 +176,12 @@ def corpus(corpus_id): @login_required @corpus_follower_permission_required('GENERATE_SHARE_LINK') def generate_corpus_share_link(corpus_id): + corpus_hashid = hashids.encode(corpus_id) data = request.get_json('data') - role = data['role'] + role_name = data['role'] exp_data = data['expiration'] expiration = datetime.strptime(exp_data, '%b %d, %Y') - token = current_user.generate_follow_corpus_token(corpus_id, role, expiration) + token = current_user.generate_follow_corpus_token(corpus_hashid, role_name, expiration) link = url_for('corpora.follow_corpus', corpus_id=corpus_id, token=token, _external=True) return link diff --git a/app/templates/corpora/analyse_corpus.concordance.html.j2 b/app/templates/corpora/analyse_corpus.concordance.html.j2 index 56baf07d..15682431 100644 --- a/app/templates/corpora/analyse_corpus.concordance.html.j2 +++ b/app/templates/corpora/analyse_corpus.concordance.html.j2 @@ -12,6 +12,8 @@ help Corpus Query Language tutorial | info Tagsets + | + info Examples
arrow_forward diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index 69bcfd6e..5abd96df 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -245,6 +245,12 @@
+ +