nopaque/app/corpora/pj_views.py
2020-04-06 14:09:41 +02:00

29 lines
1.2 KiB
Python

from flask import request, render_template
from flask_login import login_required
from . import corpora
from .pj_forms import DisplayOptionsForm, QueryForm, QueryDownloadForm
from .. import db
from ..models import Corpus
@corpora.route('/<int:corpus_id>/pj_analyse')
@login_required
def pj_analyse_corpus(corpus_id):
corpus = Corpus.query.get_or_404(corpus_id)
if corpus.status == 'prepared':
corpus.status = 'start analysis'
db.session.commit()
display_options_form = DisplayOptionsForm(
prefix='display-options-form',
result_context=request.args.get('context', 20),
results_per_page=request.args.get('results_per_page', 30))
query_form = QueryForm(prefix='query-form',
query=request.args.get('query'))
query_download_form = QueryDownloadForm()
return render_template('corpora/pj_analyse_corpus.html.j2',
corpus_id=corpus_id,
display_options_form=display_options_form,
query_form=query_form,
query_download_form=query_download_form,
title='Corpus analysis')