diff --git a/app/main/views.py b/app/main/views.py index 52dce8d4..5ef53c42 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -6,6 +6,7 @@ from . import main from .forms import CreateCorpusForm from .. import db from ..models import Corpus, CorpusFile, Job +from werkzeug.utils import secure_filename import os import threading @@ -38,7 +39,7 @@ def corpus(corpus_id): return render_template('main/corpora/corpus.html.j2', corpus=corpus, files=files, - title='Corpus') + title='Corpus: ' + corpus.title) @main.route('/corpora//download') @@ -61,6 +62,15 @@ def corpus_download(corpus_id): filename=file) +@main.route('/corpora//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']) @login_required def dashboard(): @@ -85,15 +95,16 @@ def dashboard(): flash('OSError!') else: for file in create_corpus_form.files.data: - file.save(os.path.join(dir, file.filename)) - dir = os.path.join(str(corpus.user_id), - 'corpora', - str(corpus.id)) - corpus_file = CorpusFile(filename=file.filename, + filename = secure_filename(file.filename) + file.save(os.path.join(dir, filename)) + file_dir = os.path.join(str(corpus.user_id), + 'corpora', + str(corpus.id)) + corpus_file = CorpusFile(filename=filename, corpus_id=corpus.id, - dir=dir) + dir=file_dir) db.session.add(corpus_file) - db.session.commit() + db.session.commit() flash('Corpus created!') return redirect(url_for('main.dashboard')) diff --git a/app/services/views.py b/app/services/views.py index 528545a2..e3ad4b5a 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -53,7 +53,6 @@ def service(service_handle): db.session.commit() else: for file in new_job_form.files.data: - ''' TODO: Use secure filename ''' filename = secure_filename(file.filename) file.save(os.path.join(dir, filename)) job_input = JobInput(filename=filename, job=job) diff --git a/app/static/css/opaque.css b/app/static/css/opaque.css index f46e2f60..7fa300c9 100644 --- a/app/static/css/opaque.css +++ b/app/static/css/opaque.css @@ -73,3 +73,11 @@ indicator will show up how the column is sorted right now.; */ top:-10px; right:-5px; } + +/* Sticy side elements */ +.sticky { + position: -webkit-sticky; + position: sticky; + top: 80px; + padding: 50px; +}