aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui/items.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy/web_ui/items.py')
-rw-r--r--src/hydrilla/proxy/web_ui/items.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/hydrilla/proxy/web_ui/items.py b/src/hydrilla/proxy/web_ui/items.py
index a781856..1a56d7d 100644
--- a/src/hydrilla/proxy/web_ui/items.py
+++ b/src/hydrilla/proxy/web_ui/items.py
@@ -47,16 +47,11 @@ from .. import state as st
from . import _app
-class InvalidUploadedMalcontent(HaketiloException):
- def __init__(self):
- super().__init__(_('err.proxy.uploaded_malcontent_invalid'))
-
-
bp = flask.Blueprint('items', __package__)
@bp.route('/load_from_disk', methods=['GET'])
-def load_from_disk() -> werkzeug.Response:
- html = flask.render_template('items/load_from_disk.html.jinja')
+def load_from_disk(errors: t.Mapping[str, bool] = {}) -> werkzeug.Response:
+ html = flask.render_template('items/load_from_disk.html.jinja', **errors)
return flask.make_response(html, 200)
@bp.route('/load_from_disk', methods=['POST'])
@@ -74,11 +69,11 @@ def load_from_disk_post() -> werkzeug.Response:
with zipfile.ZipFile(zip_file_storage) as zip_file:
zip_file.extractall(tmpdir_child)
except:
- raise HaketiloException(_('err.proxy.uploaded_file_not_zip'))
+ return load_from_disk({'uploaded_file_not_zip': True})
extracted_top_level_files = tuple(tmpdir_child.iterdir())
if extracted_top_level_files == ():
- raise InvalidUploadedMalcontent()
+ return load_from_disk({'invalid_uploaded_malcontent': True})
if len(extracted_top_level_files) == 1 and \
extracted_top_level_files[0].is_dir():
@@ -89,7 +84,7 @@ def load_from_disk_post() -> werkzeug.Response:
try:
_app.get_haketilo_state().import_items(malcontent_dir_path)
except:
- raise InvalidUploadedMalcontent()
+ return load_from_disk({'invalid_uploaded_malcontent': True})
return flask.redirect(flask.url_for('.packages'))