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