Add separate messages for invited/team member

2 messages seems like a good idea.
This commit is contained in:
Chris Hill-Scott
2021-01-08 10:56:59 +00:00
parent a68dfae5c2
commit fbd58ef1f8
4 changed files with 40 additions and 16 deletions

View File

@@ -65,10 +65,12 @@ def invite_user(service_id, user_id=None):
if user_id:
user_to_invite = User.from_id(user_id)
if (
user_to_invite.belongs_to_service(current_service.id)
or current_service.invite_pending_for(user_to_invite.email_address)
):
if user_to_invite.belongs_to_service(current_service.id):
return render_template(
'views/user-already-team-member.html',
user_to_invite=user_to_invite,
)
if current_service.invite_pending_for(user_to_invite.email_address):
return render_template(
'views/user-already-invited.html',
user_to_invite=user_to_invite,

View File

@@ -2,18 +2,19 @@
{% from "components/page-header.html" import page_header %}
{% block service_page_title %}
This person is already a team member
This person has already received an invite
{% endblock %}
{% block maincolumn_content %}
{{ page_header(
'{} is already a team member'.format(user_to_invite.name),
'This person has already received an invite',
back_link=url_for('main.manage_users', service_id=current_service.id)
) }}
<p class="govuk-body">
Someones already invited them. You do not need to do anything.
{{ user_to_invite.name }} has not accepted their invitation to
{{ current_service.name }} yet. You do not need to do anything.
</p>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends "withnav_template.html" %}
{% from "components/page-header.html" import page_header %}
{% block service_page_title %}
This person is already a team member
{% endblock %}
{% block maincolumn_content %}
{{ page_header(
'This person is already a team member',
back_link=url_for('main.manage_users', service_id=current_service.id)
) }}
<p class="govuk-body">
{{ user_to_invite.name }} is already member of {{ current_service.name }}.
</p>
{% endblock %}

View File

@@ -865,19 +865,16 @@ def test_should_show_page_if_prefilled_user_is_already_a_team_member(
'main.invite_user',
service_id=SERVICE_ONE_ID,
user_id=fake_uuid,
# We have the users name in the H1 but dont want it duplicated
# in the page title
_test_page_title=False,
)
assert normalize_spaces(page.select_one('title').text).startswith(
'This person is already a team member'
)
assert normalize_spaces(page.select_one('h1').text) == (
'Test User is already a team member'
'This person is already a team member'
)
assert normalize_spaces(page.select_one('main .govuk-body').text) == (
'Someones already invited them. You do not need to do anything.'
'Test User is already member of service one.'
)
assert not page.select("form")
@@ -904,14 +901,19 @@ def test_should_show_page_if_prefilled_user_is_already_invited(
'main.invite_user',
service_id=SERVICE_ONE_ID,
user_id=fake_uuid,
# We have the users name in the H1 but dont want it duplicated
# in the page title
_test_page_title=False,
)
assert normalize_spaces(page.select_one('title').text).startswith(
'This person is already a team member'
'This person has already received an invite'
)
assert normalize_spaces(page.select_one('h1').text) == (
'This person has already received an invite'
)
assert normalize_spaces(page.select_one('main .govuk-body').text) == (
'Service Two User has not accepted their invitation to '
'service one yet. You do not need to do anything.'
)
assert not page.select("form")
def test_should_403_if_trying_to_prefill_email_address_for_user_with_no_organisation(