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('//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('//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')