only send emails if a user signed the MOU

the agreement_signed field can also be edited by a platform admin - if
that happened we might not have details for who signed it, and even if
we did they shouldn't find out about, and we don't need an email since
we were the ones who clicked the button.

the `agreement_signed_by` field is only set when a user confirms that
they are signing the MOU on the admin page - not if a platform admin
modifies the page from the platform admin page
This commit is contained in:
Leo Hemsted
2019-07-04 15:12:08 +01:00
parent 07bb0f0332
commit 8e32995c8d
2 changed files with 6 additions and 4 deletions

View File

@@ -96,7 +96,9 @@ def update_organisation(organisation_id):
result = dao_update_organisation(organisation_id, **data)
if data.get('agreement_signed') is True:
send_notifications_on_mou_signed(organisation_id)
# if a platform admin has manually adjusted the organisation, don't tell people
if data.get('agreement_signed_by_id'):
send_notifications_on_mou_signed(organisation_id)
if result:
return '', 204
@@ -159,6 +161,7 @@ def check_request_args(request):
def send_notifications_on_mou_signed(organisation_id):
organisation = dao_get_organisation_by_id(organisation_id)
notify_service = dao_fetch_service_by_id(current_app.config['NOTIFY_SERVICE_ID'])
def _send_notification(template_id, recipient, personalisation):
@@ -178,7 +181,6 @@ def send_notifications_on_mou_signed(organisation_id):
send_notification_to_queue(saved_notification, research_mode=False, queue=QueueNames.NOTIFY)
organisation = dao_get_organisation_by_id(organisation_id)
personalisation = {
'mou_link': '{}/agreement/{}.pdf'.format(
current_app.config['ADMIN_BASE_URL'],