Add human-readable form of a government domain

This makes it easier to write a good message in the request to go live
submission. And encapsulating it in the `GovernmentDomain` class keeps
the view nice and clean.
This commit is contained in:
Chris Hill-Scott
2018-03-08 16:44:09 +00:00
parent ce704a979d
commit d92ecc9237
5 changed files with 57 additions and 4 deletions

View File

@@ -53,6 +53,8 @@ innovateuk.gov.uk:
ncsc.gov.uk:
owner: National Cyber Security Center
agreement_signed: true
nhs.net:
owner: NHS
nhsdigital.nhs.uk: digital.nhs.uk
digital.nhs.uk:
owner: NHS Digital

View File

@@ -172,7 +172,6 @@ def request_to_go_live(service_id):
@user_has_permissions('manage_service')
def submit_request_to_go_live(service_id):
form = RequestToGoLiveForm()
agreement_info = GovernmentDomain.from_current_user()
if form.validate_on_submit():
try:
@@ -182,7 +181,7 @@ def submit_request_to_go_live(service_id):
'On behalf of {} ({})\n'
'\n---'
'\nOrganisation type: {}'
'\nAgreement signed: {} ({})'
'\nAgreement signed: {}'
'\nMOU in place: {}'
'\nChannel: {}\nStart date: {}\nStart volume: {}'
'\nPeak volume: {}'
@@ -191,7 +190,7 @@ def submit_request_to_go_live(service_id):
current_service['name'],
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
current_service['organisation_type'],
agreement_info.agreement_signed, agreement_info.owner,
GovernmentDomain.from_current_user().as_human_readable,
form.mou.data,
formatted_list(filter(None, (
'email' if form.channel_email.data else None,

View File

@@ -470,6 +470,26 @@ class GovernmentDomain:
def from_current_user(cls):
return cls.from_user(current_user)
@property
def as_human_readable(self):
if self.agreement_signed:
return 'Yes, on behalf of {}'.format(self.owner)
elif self.owner:
return '{} (organisation is {}, {})'.format(
{
False: 'No',
None: 'Cant tell',
}.get(self.agreement_signed),
self.owner,
{
True: 'a crown body',
False: 'a non-crown body',
None: 'crown status unknown',
}.get(self.crown_status),
)
else:
return 'Cant tell'
@staticmethod
def get_matching_function(email_address_or_domain):