diff --git a/README.md b/README.md index ff9c3a8b..4e65c3b1 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,15 @@ $ nopaque.env # Fill out the empty variables within this file. 5. **Start your instance** ``` bash # Execute the following 3 steps only on first startup -$ docker-compose run web flask upgrade -$ docker-compose run web flask insert-initial-database-entries +$ docker-compose run web flask db upgrade +$ docker-compose run web flask db insert-initial-database-entries $ docker-compose down $ docker-compose up ``` + +6. **Alter Database Models** +``` bash +$ docker-compose run web flask db migrate +$ docker-compose run web flask db upgrade +``` diff --git a/app/corpora/forms.py b/app/corpora/forms.py index 313b9d51..9d97c496 100644 --- a/app/corpora/forms.py +++ b/app/corpora/forms.py @@ -5,12 +5,20 @@ from wtforms.validators import DataRequired, Length class AddCorpusFileForm(FlaskForm): - author = StringField('Author', validators=[DataRequired(), Length(1, 64)]) + address = StringField('Adress', validators=[Length(0, 255)]) + author = StringField('Author', validators=[DataRequired(), Length(1, 255)]) + booktitle = StringField('Booktitle', validators=[Length(0, 255)]) + chapter = StringField('Chapter', validators=[Length(0, 255)]) + editor = StringField('Editor', validators=[Length(0, 255)]) file = FileField('File', validators=[DataRequired()]) - publishing_year = IntegerField('Publishing year', - validators=[DataRequired()]) + institution = StringField('institution', validators=[Length(0, 255)]) + journal = StringField('Journal', validators=[Length(0, 255)]) + pages = StringField('pages', validators=[Length(0, 255)]) + publisher = StringField('Publisher', validators=[Length(0, 255)]) + publishing_year = IntegerField('Publishing year', validators=[DataRequired()]) + school = StringField('School', validators=[Length(0, 255)]) submit = SubmitField() - title = StringField('Title', validators=[DataRequired(), Length(1, 64)]) + title = StringField('Title', validators=[DataRequired(), Length(1, 255)]) def validate_file(form, field): if not field.data.filename.lower().endswith('.vrt'): diff --git a/app/models.py b/app/models.py index 32f0d109..e3b6c1cf 100644 --- a/app/models.py +++ b/app/models.py @@ -369,11 +369,20 @@ class CorpusFile(db.Model): __tablename__ = 'corpus_files' # Primary key id = db.Column(db.Integer, primary_key=True) - author = db.Column(db.String(64)) + address = db.Column(db.String(255)) + author = db.Column(db.String(255)) + booktitle = db.Column(db.String(255)) + chapter = db.Column(db.String(255)) dir = db.Column(db.String(255)) + editor = db.Column(db.String(255)) filename = db.Column(db.String(255)) + institution = db.Column(db.String(255)) + journal = db.Column(db.String(255)) + pages = db.Column(db.String(255)) + publisher = db.Column(db.String(255)) publishing_year = db.Column(db.Integer) - title = db.Column(db.String(64)) + school = db.Column(db.String(255)) + title = db.Column(db.String(255)) corpus_id = db.Column(db.Integer, db.ForeignKey('corpora.id')) def delete(self): @@ -394,8 +403,17 @@ class CorpusFile(db.Model): self.dir, self.filename) element_tree = ET.parse(file) text_node = element_tree.find('text') + text_node.set('address', self.address) text_node.set('author', self.author) + text_node.set('booktitle', self.booktitle) + text_node.set('chapter', self.chapter) + text_node.set('editor', self.editor) + text_node.set('institution', self.institution) + text_node.set('journal', self.journal) + text_node.set('pages', self.pages) + text_node.set('publisher', self.publisher) text_node.set('publishing_year', str(self.publishing_year)) + text_node.set('school', self.school) text_node.set('title', self.title) element_tree.write(file) self.corpus.status = 'unprepared' diff --git a/app/templates/corpora/add_corpus_file.html.j2 b/app/templates/corpora/add_corpus_file.html.j2 index 6a0ad009..abd0e691 100644 --- a/app/templates/corpora/add_corpus_file.html.j2 +++ b/app/templates/corpora/add_corpus_file.html.j2 @@ -7,9 +7,10 @@
+
-
+ Required metadata {{ add_corpus_file_form.hidden_tag() }}
@@ -61,7 +62,29 @@
- -
+
+
+
    +
  • +
    addAdd additional metadata
    +
    + +
    +
    +
    + person + {{ add_corpus_file_form.author(data_length='64') }} + {{ add_corpus_file_form.author.label }} + {% for error in add_corpus_file_form.author.errors %} + {{ error }} + {% endfor %} +
    +
    +
    +
    +
    +
  • +
+
{% endblock %} diff --git a/migrations/versions/ded5a37f8a7b_.py b/migrations/versions/ded5a37f8a7b_.py new file mode 100644 index 00000000..141e4786 --- /dev/null +++ b/migrations/versions/ded5a37f8a7b_.py @@ -0,0 +1,44 @@ +"""empty message + +Revision ID: ded5a37f8a7b +Revises: 776761fb7466 +Create Date: 2020-01-08 14:39:32.182439 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ded5a37f8a7b' +down_revision = '776761fb7466' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('corpus_files', sa.Column('address', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('booktitle', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('chapter', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('editor', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('institution', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('journal', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('pages', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('publisher', sa.String(length=255), nullable=True)) + op.add_column('corpus_files', sa.Column('school', sa.String(length=255), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('corpus_files', 'school') + op.drop_column('corpus_files', 'publisher') + op.drop_column('corpus_files', 'pages') + op.drop_column('corpus_files', 'journal') + op.drop_column('corpus_files', 'institution') + op.drop_column('corpus_files', 'editor') + op.drop_column('corpus_files', 'chapter') + op.drop_column('corpus_files', 'booktitle') + op.drop_column('corpus_files', 'address') + # ### end Alembic commands ###