From 89bcf19551232b39ad19a5e34bba24897fd94ba8 Mon Sep 17 00:00:00 2001 From: Arun Prasad Date: Wed, 5 Oct 2022 19:20:02 -0700 Subject: [PATCH] [proofing] Hide proofing button for unauth users A few users have tried making changes, clicked submit, and found that their changes were lost. A proper flow here will prompt login and save user changes. But for now, just hide the button and add another warning. Test plan: unit tests and tried it on dev. --- ambuda/templates/macros/components.html | 2 +- ambuda/templates/proofing/pages/edit.html | 18 +++++++++++++++--- test/ambuda/views/proofing/test_page.py | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ambuda/templates/macros/components.html b/ambuda/templates/macros/components.html index f6bf6682..e4df6e58 100644 --- a/ambuda/templates/macros/components.html +++ b/ambuda/templates/macros/components.html @@ -3,7 +3,7 @@ {# Small warning box, e.g. for form errors. #} {% macro p_warning() %} -

+

{{ caller() }}

{% endmacro %} diff --git a/ambuda/templates/proofing/pages/edit.html b/ambuda/templates/proofing/pages/edit.html index e8acdb89..0103d24c 100644 --- a/ambuda/templates/proofing/pages/edit.html +++ b/ambuda/templates/proofing/pages/edit.html @@ -1,6 +1,6 @@ {% extends 'proofing/base.html' %} {% import "macros/proofing.html" as m %} -{% import "macros/components.html" as site_components %} +{% import "macros/components.html" as mc %} {% import "proofing/pages/editor-components.html" as editor %} @@ -24,7 +24,7 @@
{% if not current_user.is_authenticated -%} {% set url = url_for('auth.register') %} - {% call site_components.p_warning() %}{% trans %} + {% call mc.p_warning() %}{% trans %} Since you are not logged in, some functions (such as the OCR button) have been disabled. To use all website features, please create an account. @@ -57,7 +57,7 @@ {{ editor.image_box() }} -
+
{{ form.summary.label(class_="text-slate-600 mb-2 block") }} {{ form.summary(class_="block rounded bg-white w-full mb-4 p-2", placeholder=_("Fixed various OCR errors")) }} @@ -77,18 +77,30 @@ "peer-checked:bg-slate-100 peer-checked:text-gray-800 peer-checked:border-gray-300") }}
+ {% if current_user.is_authenticated %} {% set cc0 = "https://creativecommons.org/publicdomain/zero/1.0/" %}

{% trans %} By saving your changes, you agree to release your contribution under the CC0 (public domain) license. {% endtrans %}

+ + {% endif %}
+ {% if not current_user.is_authenticated %} + {% set create = url_for("auth.register") %} + {% set log_in = url_for("auth.sign_in") %} + {% call mc.p_warning() %} + Only registered users can save changes. Create an + account or sign in to save your + changes. + {% endcall %} + {% endif %}
diff --git a/test/ambuda/views/proofing/test_page.py b/test/ambuda/views/proofing/test_page.py index 1694bcd4..4dc5e3aa 100644 --- a/test/ambuda/views/proofing/test_page.py +++ b/test/ambuda/views/proofing/test_page.py @@ -10,6 +10,7 @@ def test_get_image_filesystem_path(flask_app): def test_edit__unauth(client): r = client.get("/proofing/test-project/1/") assert "Since you are not logged in" in r.text + assert "Publish changes" not in r.text def test_edit__auth(rama_client):