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

@@ -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):