diff --git a/app/main/forms.py b/app/main/forms.py index 80e6becf..20826e48 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -7,10 +7,17 @@ from wtforms.validators import DataRequired, Length, NumberRange class CreateCorpusForm(FlaskForm): description = StringField('Description', validators=[DataRequired(), Length(1, 64)]) - files = MultipleFileField('Files', validators=[DataRequired()]) submit = SubmitField('Create corpus') title = StringField('Title', validators=[DataRequired(), Length(1, 32)]) + +class AddCorpusFileForm(FlaskForm): + author = StringField('Author', validators=[DataRequired(), Length(1, 64)]) + files = MultipleFileField('Files', validators=[DataRequired()]) + publishing_year = IntegerField('Publishing year', validators=[DataRequired()]) + submit = SubmitField() + title = StringField('Title', validators=[DataRequired(), Length(1, 64)]) + def validate_files(form, field): for file in field.data: if not file.filename.lower().endswith('.vrt'): diff --git a/app/main/views.py b/app/main/views.py index 9a573a9f..bff10de1 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -3,7 +3,7 @@ from flask import (abort, current_app, flash, redirect, request, render_template, url_for, send_from_directory) from flask_login import current_user, login_required from . import main -from .forms import CreateCorpusForm, QueryForm +from .forms import AddCorpusFileForm, CreateCorpusForm, QueryForm from .. import db from ..models import Corpus, CorpusFile, Job, JobInput, JobResult from werkzeug.utils import secure_filename @@ -24,7 +24,12 @@ def corpus(corpus_id): if not (corpus.creator == current_user or current_user.is_administrator()): abort(403) + add_corpus_file_form = AddCorpusFileForm() + if add_corpus_file_form.validate_on_submit(): + flash('Corpus file added!') + return redirect(url_for('main.corpus', corpus_id=corpus_id)) return render_template('main/corpora/corpus.html.j2', + add_corpus_file_form=add_corpus_file_form, corpus=corpus, title='Corpus') diff --git a/app/models.py b/app/models.py index fbff582d..9f416c64 100644 --- a/app/models.py +++ b/app/models.py @@ -403,8 +403,11 @@ class CorpusFile(db.Model): __tablename__ = 'corpus_files' # Primary key id = db.Column(db.Integer, primary_key=True) - filename = db.Column(db.String(255)) + author = db.Column(db.String(64)) dir = db.Column(db.String(255)) + filename = db.Column(db.String(255)) + publishing_year = db.Column(db.Integer) + title = db.Column(db.String(64)) corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id')) diff --git a/app/templates/main/corpora/corpus.html.j2 b/app/templates/main/corpora/corpus.html.j2 index 1414cb76..5896af60 100644 --- a/app/templates/main/corpora/corpus.html.j2 +++ b/app/templates/main/corpora/corpus.html.j2 @@ -4,11 +4,6 @@
+ + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,