Commit 6d26e44d authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Check file existence in upload forms

/close #207
parent 6169b469
...@@ -823,7 +823,7 @@ def etherpull_protocol(protocol): ...@@ -823,7 +823,7 @@ def etherpull_protocol(protocol):
def upload_source_to_known_protocol(protocol): def upload_source_to_known_protocol(protocol):
form = KnownProtocolSourceUploadForm() form = KnownProtocolSourceUploadForm()
if form.validate_on_submit(): if form.validate_on_submit():
if form.source.data is None: if form.source.data is None or isinstance(form.source.data, str):
flash("Es wurde keine Datei ausgewählt.", "alert-error") flash("Es wurde keine Datei ausgewählt.", "alert-error")
else: else:
file = form.source.data file = form.source.data
...@@ -846,7 +846,7 @@ def upload_new_protocol(): ...@@ -846,7 +846,7 @@ def upload_new_protocol():
available_types = ProtocolType.get_modifiable_protocoltypes(user) available_types = ProtocolType.get_modifiable_protocoltypes(user)
form = NewProtocolSourceUploadForm(protocoltypes=available_types) form = NewProtocolSourceUploadForm(protocoltypes=available_types)
if form.validate_on_submit(): if form.validate_on_submit():
if form.source.data is None: if form.source.data is None or isinstance(form.source.data, str):
flash("Es wurde keine Datei ausgewählt.", "alert-error") flash("Es wurde keine Datei ausgewählt.", "alert-error")
return redirect(request.args.get("fail") return redirect(request.args.get("fail")
or url_for("new_protocol")) or url_for("new_protocol"))
...@@ -880,7 +880,7 @@ def upload_new_protocol_by_file(): ...@@ -880,7 +880,7 @@ def upload_new_protocol_by_file():
available_types = ProtocolType.get_modifiable_protocoltypes(user) available_types = ProtocolType.get_modifiable_protocoltypes(user)
form = NewProtocolFileUploadForm(protocoltypes=available_types) form = NewProtocolFileUploadForm(protocoltypes=available_types)
if form.validate_on_submit(): if form.validate_on_submit():
if form.file.data is None: if form.file.data is None or isinstance(form.file.data, str):
flash("Es wurde keine Datei ausgewählt.", "alert-error") flash("Es wurde keine Datei ausgewählt.", "alert-error")
return redirect(request.args.get("fail") return redirect(request.args.get("fail")
or url_for("new_protocol")) or url_for("new_protocol"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment