aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui/root.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-09-27 11:25:00 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-29 10:47:13 +0200
commit05f1f813fa5dad4e9794dcccb0ea24e75a215029 (patch)
treecdd3f85dc0831afe5fcf6d707bc204f39f538920 /src/hydrilla/proxy/web_ui/root.py
parentc28cb95b39c4f5b76301dfb4d461bc88f8c8c1e6 (diff)
downloadhaketilo-hydrilla-05f1f813fa5dad4e9794dcccb0ea24e75a215029.tar.gz
haketilo-hydrilla-05f1f813fa5dad4e9794dcccb0ea24e75a215029.zip
[proxy] remove options page in web UI and move options to proxy's home page
Diffstat (limited to 'src/hydrilla/proxy/web_ui/root.py')
-rw-r--r--src/hydrilla/proxy/web_ui/root.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index 21c491b..a28fde8 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -45,7 +45,6 @@ from ...translations import translation as make_translation
from ... import item_infos
from .. import state as st
from .. import http_messages
-from . import options
from . import rules
from . import repos
from . import items
@@ -100,7 +99,7 @@ class WebUIAppImpl(_app.WebUIApp):
self.before_request(authenticate_by_referrer)
- for blueprint in [rules.bp, repos.bp, items.bp, prompts.bp, options.bp]:
+ for blueprint in [rules.bp, repos.bp, items.bp, prompts.bp]:
self.register_blueprint(blueprint)
# Flask app is not thread-safe and has to be accompanied by an ugly lock. This
@@ -110,10 +109,35 @@ app = WebUIAppImpl()
app_lock = Lock()
-@app.route('/')
-def home() -> str:
- return flask.render_template('index.html.jinja')
-
+@app.route('/', methods=['GET'])
+def home(errors: t.Mapping[str, bool] = {}) -> werkzeug.Response:
+ html = flask.render_template('index.html.jinja', **errors)
+ return flask.make_response(html, 200)
+
+@app.route('/', methods=['POST'])
+def home_post() -> werkzeug.Response:
+ action = flask.request.form['action']
+
+ state = _app.get_haketilo_state()
+
+ if action == 'use_enabled':
+ state.update_settings(mapping_use_mode=st.MappingUseMode.WHEN_ENABLED)
+ elif action == 'use_auto':
+ state.update_settings(mapping_use_mode=st.MappingUseMode.AUTO)
+ elif action == 'use_question':
+ state.update_settings(mapping_use_mode=st.MappingUseMode.QUESTION)
+ elif action == 'allow_scripts':
+ state.update_settings(default_allow_scripts=True)
+ elif action == 'block_scripts':
+ state.update_settings(default_allow_scripts=False)
+ elif action == 'user_make_advanced':
+ state.update_settings(advanced_user=True)
+ elif action == 'user_make_simple':
+ state.update_settings(advanced_user=False)
+ else:
+ raise ValueError()
+
+ return flask.redirect(flask.url_for('.home'), 303)
def process_request(
request_info: http_messages.RequestInfo,