From bdfeb08055f2b8b92a83570edcece8432a758309 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 5 Mar 2020 11:26:08 +0000 Subject: [PATCH] Let the Notify team invite people to an organisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to start granting access to the org page. But it will be a bit weird if the invites come from us personally, since the people we’re inviting don’t know us. It makes more sense, and sounds more official if the invites appear to come from the ‘GOV.UK Notify team’ instead. --- app/organisation/invite_rest.py | 6 +++++- tests/app/organisation/test_invite_rest.py | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/organisation/invite_rest.py b/app/organisation/invite_rest.py index 36c3602d1..490c7e402 100644 --- a/app/organisation/invite_rest.py +++ b/app/organisation/invite_rest.py @@ -48,7 +48,11 @@ def invite_user_to_org(organisation_id): recipient=invited_org_user.email_address, service=template.service, personalisation={ - 'user_name': invited_org_user.invited_by.name, + 'user_name': ( + 'The GOV.UK Notify team' + if invited_org_user.invited_by.platform_admin + else invited_org_user.invited_by.name + ), 'organisation_name': invited_org_user.organisation.name, 'url': invited_org_user_url( invited_org_user.id, diff --git a/tests/app/organisation/test_invite_rest.py b/tests/app/organisation/test_invite_rest.py index b957ed912..c0092511b 100644 --- a/tests/app/organisation/test_invite_rest.py +++ b/tests/app/organisation/test_invite_rest.py @@ -5,6 +5,10 @@ from app.models import Notification, INVITE_PENDING from tests.app.db import create_invited_org_user +@pytest.mark.parametrize('platform_admin, expected_invited_by', ( + (True, 'The GOV.UK Notify team'), + (False, 'Test User') +)) @pytest.mark.parametrize('extra_args, expected_start_of_invite_url', [ ( {}, @@ -23,9 +27,12 @@ def test_create_invited_org_user( org_invite_email_template, extra_args, expected_start_of_invite_url, + platform_admin, + expected_invited_by, ): mocked = mocker.patch('app.celery.provider_tasks.deliver_email.apply_async') email_address = 'invited_user@example.com' + sample_user.platform_admin = platform_admin data = dict( organisation=str(sample_organisation.id), @@ -53,7 +60,7 @@ def test_create_invited_org_user( assert len(notification.personalisation.keys()) == 3 assert notification.personalisation['organisation_name'] == 'sample organisation' - assert notification.personalisation['user_name'] == 'Test User' + assert notification.personalisation['user_name'] == expected_invited_by assert notification.personalisation['url'].startswith(expected_start_of_invite_url) assert len(notification.personalisation['url']) > len(expected_start_of_invite_url)