Stop showing link for cancelled org users

This commit is contained in:
Katie Smith
2022-01-12 11:49:58 +00:00
parent daed4a7f7f
commit f3baacfb56
2 changed files with 21 additions and 1 deletions

View File

@@ -54,7 +54,7 @@
<div class="govuk-grid-column-one-quarter">
{% if user.status == 'pending' %}
<a class="govuk-link govuk-link--no-visited-state user-list-edit-link" href="{{ url_for('.cancel_invited_org_user', org_id=current_org.id, invited_user_id=user.id)}}">Cancel invitation<span class="govuk-visually-hidden"> for {{ user.email_address }}</span></a>
{% else %}
{% elif user.status != 'cancelled' %}
<a class="govuk-link govuk-link--destructive user-list-edit-link" href="{{ url_for('.edit_organisation_user', org_id=current_org.id, user_id=user.id)}}">Remove<span class="govuk-visually-hidden"> {{ user.name }} {{ user.email_address }}</span></a>
{% endif %}
</div>

View File

@@ -801,6 +801,26 @@ def test_manage_org_users_shows_correct_link_next_to_each_user(
assert users[2].a['href'] == url_for('.edit_organisation_user', org_id=ORGANISATION_ID, user_id='5678')
def test_manage_org_users_shows_no_link_for_cancelled_users(
client_request,
mock_get_organisation,
mock_get_users_for_organisation,
sample_org_invite,
mocker,
):
sample_org_invite['status'] = 'cancelled'
mocker.patch('app.models.user.OrganisationInvitedUsers.client_method', return_value=[sample_org_invite])
page = client_request.get(
'.manage_org_users',
org_id=ORGANISATION_ID,
)
users = page.find_all(class_='user-list-item')
assert normalize_spaces(users[0].text) == 'invited_user@test.gov.uk (cancelled invite)'
assert not users[0].a
@pytest.mark.parametrize('number_of_users', (
pytest.param(7, marks=pytest.mark.xfail),
pytest.param(8),