Add first Corpus analysis page

This commit is contained in:
Stephan Porada 2019-10-24 13:14:15 +02:00
parent dce834c9a1
commit 3e622ac553
3 changed files with 27 additions and 9 deletions

View File

@ -6,6 +6,7 @@ from . import main
from .forms import CreateCorpusForm from .forms import CreateCorpusForm
from .. import db from .. import db
from ..models import Corpus, CorpusFile, Job from ..models import Corpus, CorpusFile, Job
from werkzeug.utils import secure_filename
import os import os
import threading import threading
@ -38,7 +39,7 @@ def corpus(corpus_id):
return render_template('main/corpora/corpus.html.j2', return render_template('main/corpora/corpus.html.j2',
corpus=corpus, corpus=corpus,
files=files, files=files,
title='Corpus') title='Corpus: ' + corpus.title)
@main.route('/corpora/<int:corpus_id>/download') @main.route('/corpora/<int:corpus_id>/download')
@ -61,6 +62,15 @@ def corpus_download(corpus_id):
filename=file) filename=file)
@main.route('/corpora/<int:corpus_id>/analysis')
@login_required
def corpus_analysis(corpus_id):
corpus = Corpus.query.get_or_404(corpus_id)
return render_template('main/corpora/corpus_analysis.html.j2',
corpus=corpus,
title='Corpus: ' + corpus.title)
@main.route('/dashboard', methods=['GET', 'POST']) @main.route('/dashboard', methods=['GET', 'POST'])
@login_required @login_required
def dashboard(): def dashboard():
@ -85,13 +95,14 @@ def dashboard():
flash('OSError!') flash('OSError!')
else: else:
for file in create_corpus_form.files.data: for file in create_corpus_form.files.data:
file.save(os.path.join(dir, file.filename)) filename = secure_filename(file.filename)
dir = os.path.join(str(corpus.user_id), file.save(os.path.join(dir, filename))
file_dir = os.path.join(str(corpus.user_id),
'corpora', 'corpora',
str(corpus.id)) str(corpus.id))
corpus_file = CorpusFile(filename=file.filename, corpus_file = CorpusFile(filename=filename,
corpus_id=corpus.id, corpus_id=corpus.id,
dir=dir) dir=file_dir)
db.session.add(corpus_file) db.session.add(corpus_file)
db.session.commit() db.session.commit()
flash('Corpus created!') flash('Corpus created!')

View File

@ -53,7 +53,6 @@ def service(service_handle):
db.session.commit() db.session.commit()
else: else:
for file in new_job_form.files.data: for file in new_job_form.files.data:
''' TODO: Use secure filename '''
filename = secure_filename(file.filename) filename = secure_filename(file.filename)
file.save(os.path.join(dir, filename)) file.save(os.path.join(dir, filename))
job_input = JobInput(filename=filename, job=job) job_input = JobInput(filename=filename, job=job)

View File

@ -73,3 +73,11 @@ indicator will show up how the column is sorted right now.; */
top:-10px; top:-10px;
right:-5px; right:-5px;
} }
/* Sticy side elements */
.sticky {
position: -webkit-sticky;
position: sticky;
top: 80px;
padding: 50px;
}