mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-01 18:30:34 +00:00
Restructure corpora blueprint
This commit is contained in:
@ -6,6 +6,7 @@ from flask import (
|
||||
Flask,
|
||||
jsonify,
|
||||
redirect,
|
||||
request,
|
||||
render_template,
|
||||
url_for
|
||||
)
|
||||
@ -150,7 +151,7 @@ def delete_corpus(corpus_id: int):
|
||||
return jsonify(f'Corpus "{corpus.title}" marked for deletion.'), 202
|
||||
|
||||
|
||||
@bp.route('/<hashid:corpus_id>/build', methods=['PATCH'])
|
||||
@bp.route('/<hashid:corpus_id>/build', methods=['POST'])
|
||||
def build_corpus(corpus_id: int):
|
||||
corpus = Corpus.query.get_or_404(corpus_id)
|
||||
|
||||
@ -178,11 +179,15 @@ def build_corpus(corpus_id: int):
|
||||
return jsonify(f'Corpus "{corpus.title}" marked for building.'), 202
|
||||
|
||||
|
||||
@bp.route('/<hashid:corpus_id>/generate-share-link', methods=['POST'])
|
||||
def create_share_link(corpus_id: int, expiration_date: str, role_name: str):
|
||||
@bp.route('/<hashid:corpus_id>/create-share-link', methods=['POST'])
|
||||
def create_share_link(corpus_id: int):
|
||||
data = request.json
|
||||
|
||||
expiration_date = data['expiration_date']
|
||||
if not isinstance(expiration_date, str):
|
||||
abort(400)
|
||||
|
||||
role_name = data['role_name']
|
||||
if not isinstance(role_name, str):
|
||||
abort(400)
|
||||
|
||||
@ -233,8 +238,9 @@ def analysis(corpus_id: int):
|
||||
title=f'Analyse Corpus {corpus.title}'
|
||||
)
|
||||
|
||||
|
||||
@bp.route('/<hashid:corpus_id>/analysis/stopwords')
|
||||
def get_stopwords():
|
||||
def get_stopwords(corpus_id: int):
|
||||
languages = [
|
||||
'german',
|
||||
'english',
|
||||
@ -270,3 +276,24 @@ def follow_corpus(corpus_id: int, token: str):
|
||||
|
||||
flash(f'You are following "{corpus.title}" now', category='corpus')
|
||||
return redirect(corpus.url)
|
||||
|
||||
|
||||
@bp.route('/<hashid:corpus_id>/is-public', methods=['PUT'])
|
||||
def update_is_public(corpus_id):
|
||||
new_value = request.json
|
||||
if not isinstance(new_value, bool):
|
||||
abort(400)
|
||||
|
||||
corpus = Corpus.query.get_or_404(corpus_id)
|
||||
|
||||
if not (
|
||||
corpus.user == current_user
|
||||
or current_user.is_administrator
|
||||
):
|
||||
abort(403)
|
||||
|
||||
|
||||
corpus.is_public = new_value
|
||||
db.session.commit()
|
||||
|
||||
return jsonify(f'Corpus "{corpus.title}" is now {"public" if new_value else "private"}'), 200
|
||||
|
Reference in New Issue
Block a user