From a9530939c57abfd6b083600706cca223a01a3941 Mon Sep 17 00:00:00 2001 From: Marya Shariq Date: Fri, 1 Nov 2024 16:00:57 +0000 Subject: [PATCH] =?UTF-8?q?moved=20'remove=20all'=20button=20to=20right=20?= =?UTF-8?q?hand=20side=20of=20page=20and=20hidden=20this=20=E2=80=A6=20(#1?= =?UTF-8?q?310)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * moved 'remove all' button to right hand side of page and hidden this button from non-superusers * ran black linter * removed commented div tags --- workbaskets/jinja2/workbaskets/changes.jinja | 10 ++++-- workbaskets/tests/test_views.py | 34 ++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/workbaskets/jinja2/workbaskets/changes.jinja b/workbaskets/jinja2/workbaskets/changes.jinja index 7fd65eb5f..96cbca35c 100644 --- a/workbaskets/jinja2/workbaskets/changes.jinja +++ b/workbaskets/jinja2/workbaskets/changes.jinja @@ -98,9 +98,15 @@ }) }} {% endif %} -
+
+
- +
+ {% if request.user.is_superuser %} +
+ +
+ {% endif %}
{% include "includes/common/pagination.jinja" %} diff --git a/workbaskets/tests/test_views.py b/workbaskets/tests/test_views.py index 8c8213f46..73e7d6635 100644 --- a/workbaskets/tests/test_views.py +++ b/workbaskets/tests/test_views.py @@ -2605,3 +2605,37 @@ def test_current_tasks_is_called(valid_user_client): assert len(queued_checks) == 2 assert "QUEUED" in queued_checks[0].get_text() assert "QUEUED" in queued_checks[1].get_text() + + +def test_remove_all_workbasket_changes_button_only_shown_to_superusers( + client, user_workbasket, superuser +): + url = reverse( + "workbaskets:workbasket-ui-changes", + kwargs={"pk": user_workbasket.pk}, + ) + + client.force_login(superuser) + + response = client.get(url) + assert response.status_code == 200 + page = BeautifulSoup(str(response.content), "html.parser") + + remove_all_button = page.find("button", value="remove-all") + assert remove_all_button + + +def test_remove_all_workbasket_changes_button_not_shown_to_users_without_permision( + valid_user_client, user_workbasket +): + url = reverse( + "workbaskets:workbasket-ui-changes", + kwargs={"pk": user_workbasket.pk}, + ) + + response = valid_user_client.get(url) + assert response.status_code == 200 + page = BeautifulSoup(str(response.content), "html.parser") + + remove_all_button = page.find("button", value="remove-all") + assert not remove_all_button