mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-30 15:25:19 +00:00
Add function to import exported results and view them after the import
This commit is contained in:
5
web/app/results/__init__.py
Normal file
5
web/app/results/__init__.py
Normal 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
0
web/app/results/forms.py
Normal file
0
web/app/results/tables.py
Normal file
0
web/app/results/tables.py
Normal file
46
web/app/results/views.py
Normal file
46
web/app/results/views.py
Normal 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')
|
Reference in New Issue
Block a user