Add function to import exported results and view them after the import

This commit is contained in:
Stephan Porada
2020-07-03 14:41:57 +02:00
parent a997fbe0ee
commit 1811623583
27 changed files with 880 additions and 32 deletions

View File

@@ -0,0 +1,5 @@
from flask import Blueprint
results = Blueprint('results', __name__)
from . import views # noqa

0
web/app/results/forms.py Normal file
View File

View File

46
web/app/results/views.py Normal file
View File

@@ -0,0 +1,46 @@
from . import results
from ..models import Result
from flask import abort, render_template, current_app, request
from flask_login import current_user, login_required
from ..corpora.forms import DisplayOptionsForm
import json
import os
@results.route('/<int:result_id>/details')
@login_required
def result_details(result_id):
'''
View to show metadate and details about on imported result file.
'''
result = Result.query.get_or_404(result_id)
if not (result.creator == current_user or current_user.is_administrator()):
abort(403)
return render_template('results/result_details.html.j2',
result=result,
title='Result Details')
@results.route('/<int:result_id>/inspect')
@login_required
def result_inspect(result_id):
'''
View to inspect one importe result file in a corpus analysis like interface
'''
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))
result = Result.query.get_or_404(result_id)
result_file_path = os.path.join(current_app.config['NOPAQUE_STORAGE'],
result.file[0].dir,
result.file[0].filename)
with open(result_file_path, 'r') as result_json:
result_json = json.load(result_json)
if not (result.creator == current_user or current_user.is_administrator()):
abort(403)
return render_template('results/result_inspect.html.j2',
display_options_form=display_options_form,
result=result,
result_json=result_json,
title='Result Insepct')