Add validation for agreement accepted on behalf of

If the user has selected that they are accepting the agreement on behalf
of someone else then we need to make the they provide that person’s
details.

If they’ve selected that they are accepting the agreement themselves
then we have to ignore what they might have put in the ‘on behalf of
boxes’ (for example if they filled them out but then changed their
mind).
This commit is contained in:
Chris Hill-Scott
2019-06-18 15:26:04 +01:00
parent eb3f9aad2a
commit 0728d9b4fb
3 changed files with 151 additions and 39 deletions

View File

@@ -33,20 +33,10 @@ def service_agreement(service_id):
@login_required
def service_accept_agreement(service_id):
org = current_service.organisation
if not org:
if not current_service.organisation:
abort(404)
form = AcceptAgreementForm(
version=org.agreement_signed_version,
who='someone-else' if (
org.agreement_signed_on_behalf_of_name
and org.agreement_signed_on_behalf_of_email_address
) else 'me',
on_behalf_of_name=org.agreement_signed_on_behalf_of_name,
on_behalf_of_email=org.agreement_signed_on_behalf_of_email_address,
)
form = AcceptAgreementForm.from_organisation(current_service.organisation)
if form.validate_on_submit():
current_service.organisation.update(