summaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
-rw-r--r--src/hydrilla/proxy/web_ui/repos.py14
-rw-r--r--src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja10
2 files changed, 19 insertions, 5 deletions
diff --git a/src/hydrilla/proxy/web_ui/repos.py b/src/hydrilla/proxy/web_ui/repos.py
index 8c69028..ae4741f 100644
--- a/src/hydrilla/proxy/web_ui/repos.py
+++ b/src/hydrilla/proxy/web_ui/repos.py
@@ -98,17 +98,17 @@ def show_repo(repo_id: str, errors: t.Mapping[str, bool] = {}) \
@bp.route('/repos/view/<string:repo_id>', methods=['POST'])
def alter_repo(repo_id: str) -> werkzeug.Response:
+ form_data = flask.request.form
+ action = form_data['action']
+
repo_id = str(int(repo_id))
if repo_id == '1':
# Protect local semi-repo.
flask.abort(403)
- repo_ref = _app.get_haketilo_state().repo_store().get(repo_id)
-
- form_data = flask.request.form
- action = form_data['action']
-
try:
+ repo_ref = _app.get_haketilo_state().repo_store().get(repo_id)
+
if action == 'remove_repo':
repo_ref.remove()
return flask.redirect(flask.url_for('.repos'))
@@ -127,6 +127,10 @@ def alter_repo(repo_id: str) -> werkzeug.Response:
return show_repo(repo_id, {'repo_name_taken': True})
except st.RepoUrlInvalid:
return show_repo(repo_id, {'repo_url_invalid': True})
+ except st.RepoCommunicationError:
+ return show_repo(repo_id, {'repo_communication_error': True})
+ except st.RepoApiVersionUnsupported:
+ return show_repo(repo_id, {'repo_api_version_unsupported': True})
except st.MissingItemError:
flask.abort(404)
diff --git a/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja b/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
index 5783a20..b3a4f32 100644
--- a/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/repos/show_single.html.jinja
@@ -27,6 +27,16 @@ in a proprietary work, I am not going to enforce this in court.
{% include 'include/checkbox_tricks_style.css.jinja' %}
{% endblock %}
{% block main %}
+ {%- if repo_communication_error is defined %}
+ <aside class="error-note">
+ {{ _('web_ui.repos.add.repo_communication_error') }}
+ </aside>
+ {%- endif %}
+ {%- if repo_api_version_unsupported is defined %}
+ <aside class="error-note">
+ {{ _('web_ui.repos.add.repo_api_version_unsupported') }}
+ </aside>
+ {%- endif %}
{%- set repo_id = display_info.ref.id %}
{%- if display_info.is_local_semirepo %}
<h3>{{ _('web_ui.repos.local_packages_semirepo') }}</h3>