From a0e56cf05978524e8d629451b355bae348e28b9c 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 | 20 ++++++++++++++++---- test/ambuda/views/proofing/test_page.py | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ambuda/templates/macros/components.html b/ambuda/templates/macros/components.html index 59649ecd..23d8551c 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 c855f609..43c79422 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. @@ -32,7 +32,7 @@ {%- endif %} {{ editor.navigation_bar(project, cur=cur, prev=prev, next=next) }} - {{ site_components.flash_messages() }} + {{ mc.flash_messages() }} {% if conflict %}
{{ conflict.content }}
@@ -48,7 +48,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")) }} @@ -68,18 +68,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):