Skip to content

Commit

Permalink
moved 'remove all' button to right hand side of page and hidden this … (
Browse files Browse the repository at this point in the history
#1310)

* moved 'remove all' button to right hand side of page and hidden this button from non-superusers

* ran black linter

* removed commented div tags
  • Loading branch information
marya-shariq authored Nov 1, 2024
1 parent 0c85431 commit a953093
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
10 changes: 8 additions & 2 deletions workbaskets/jinja2/workbaskets/changes.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@
}) }}
{% endif %}

<div class="govuk-button-group">
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<button value="remove-selected" name="form-action" class="govuk-button govuk-button--secondary" data-module="govuk-button">Remove</button>
<button value="remove-all" name="form-action" class="govuk-button govuk-button--warning" data-module="govuk-button">Remove all workbasket changes</button>
</div>
{% if request.user.is_superuser %}
<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-4">
<button value="remove-all" name="form-action" class="govuk-button govuk-button--warning" data-module="govuk-button" style="float: right;">Remove all workbasket changes</button>
</div>
{% endif %}
</div>

{% include "includes/common/pagination.jinja" %}
Expand Down
34 changes: 34 additions & 0 deletions workbaskets/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a953093

Please sign in to comment.