From 41b08b7ca1f9328d565090dfd427ba400633b8e2 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Fri, 4 Mar 2016 15:17:04 +0000 Subject: [PATCH] Added from_user name and service name for the cancelled invitation message. --- app/main/views/invites.py | 7 ++++++- app/templates/views/cancelled-invitation.html | 7 +++++-- tests/app/main/views/test_accept_invite.py | 7 +++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/main/views/invites.py b/app/main/views/invites.py index d6d496fe0..0df0306fb 100644 --- a/app/main/views/invites.py +++ b/app/main/views/invites.py @@ -9,6 +9,7 @@ from flask import ( from notifications_python_client.errors import HTTPError from app.main import main +from app.main.dao.services_dao import get_service_by_id_or_404 from app import ( invite_api_client, user_api_client @@ -22,7 +23,11 @@ def accept_invite(token): invited_user = invite_api_client.check_token(token) if invited_user.status == 'cancelled': - return render_template('views/cancelled-invitation.html') + from_user = user_api_client.get_user(invited_user.from_user) + service = get_service_by_id_or_404(invited_user.service) + return render_template('views/cancelled-invitation.html', + from_user=from_user.name, + service_name=service['name']) existing_user = user_api_client.get_user_by_email(invited_user.email_address) diff --git a/app/templates/views/cancelled-invitation.html b/app/templates/views/cancelled-invitation.html index d1b78cd3c..1e418505f 100644 --- a/app/templates/views/cancelled-invitation.html +++ b/app/templates/views/cancelled-invitation.html @@ -4,10 +4,13 @@

- The invitation you were sent has been cancelled. + The invitation you were sent has been cancelled

- The person that sent you the invitation decided that it was sent in error and has cancelled the invitation. + {{ from_user }} decided to cancel this invitation. +

+

+ If you need access to {{ service_name }}, you’ll have to ask them to invite you again.

diff --git a/tests/app/main/views/test_accept_invite.py b/tests/app/main/views/test_accept_invite.py index 8518309fc..3a83f7578 100644 --- a/tests/app/main/views/test_accept_invite.py +++ b/tests/app/main/views/test_accept_invite.py @@ -83,7 +83,9 @@ def test_new_user_accept_invite_calls_api_and_redirects_to_registration(app_, def test_cancelled_invited_user_accepts_invited_redirect_to_cancelled_invitation(app_, service_one, - mocker + mocker, + mock_get_user, + mock_get_service ): with app_.test_request_context(): with app_.test_client() as client: @@ -93,7 +95,8 @@ def test_cancelled_invited_user_accepts_invited_redirect_to_cancelled_invitation app.invite_api_client.check_token.assert_called_with('thisisnotarealtoken') assert response.status_code == 200 - assert 'Invitation has been cancelled' in response.get_data(as_text=True) + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.h1.string.strip() == 'The invitation you were sent has been cancelled' def test_new_user_accept_invite_completes_new_registration_redirects_to_verify(app_,