mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Fix uploading corpus files
This commit is contained in:
parent
4146e3789b
commit
63217a7e1d
@ -16,7 +16,7 @@ class AddCorpusFileForm(FlaskForm):
|
||||
'''
|
||||
# Required fields
|
||||
author = StringField('Author', validators=[InputRequired(), Length(min=1, max=255)])
|
||||
publishing_year = IntegerField('Publishing year', validators=[InputRequired(), Length(min=1, max=255)])
|
||||
publishing_year = IntegerField('Publishing year', validators=[InputRequired()])
|
||||
title = StringField('Title', validators=[InputRequired(), Length(min=1, max=255)])
|
||||
vrt = FileField('File', validators=[FileRequired()])
|
||||
# Optional fields
|
||||
|
@ -195,7 +195,6 @@ def add_corpus_file(corpus_id):
|
||||
if not form.validate():
|
||||
return make_response(form.errors, 400)
|
||||
# Save the file
|
||||
filename = secure_filename(form.file.data.filename)
|
||||
corpus_file = CorpusFile(
|
||||
address=form.address.data,
|
||||
author=form.author.data,
|
||||
@ -203,7 +202,7 @@ def add_corpus_file(corpus_id):
|
||||
chapter=form.chapter.data,
|
||||
corpus=corpus,
|
||||
editor=form.editor.data,
|
||||
filename=filename,
|
||||
filename=form.vrt.data.filename,
|
||||
institution=form.institution.data,
|
||||
journal=form.journal.data,
|
||||
mimetype='application/vrt+xml',
|
||||
@ -217,7 +216,7 @@ def add_corpus_file(corpus_id):
|
||||
db.session.flush(objects=[corpus_file])
|
||||
db.session.refresh(corpus_file)
|
||||
try:
|
||||
form.file.data.save(corpus_file.path)
|
||||
form.vrt.data.save(corpus_file.path)
|
||||
except OSError as e:
|
||||
current_app.logger.error(e)
|
||||
db.session.rollback()
|
||||
|
@ -46,7 +46,7 @@
|
||||
<div class="collapsible-header"><i class="material-icons">add</i>Add additional metadata</div>
|
||||
<div class="collapsible-body">
|
||||
{% for field in form
|
||||
if field.short_name not in ['author', 'csrf_token', 'file', 'publishing_year', 'submit', 'title'] %}
|
||||
if field.short_name not in ['author', 'csrf_token', 'vrt', 'publishing_year', 'submit', 'title'] %}
|
||||
{{ wtf.render_field(field, material_icon=field.label.text[0:1]) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user