Move unknown organisation logic into Jinja

Human readable content like this doesn’t really belong in the model
layer, it’s more natural to have it in the presentation layer.
This commit is contained in:
Chris Hill-Scott
2021-10-11 15:24:55 +01:00
parent eefc903b25
commit 72742cf477
3 changed files with 5 additions and 18 deletions

View File

@@ -520,5 +520,7 @@ def format_billions(count):
return humanize.intword(count)
def format_yes_no(value):
return 'Yes' if value else 'No'
def format_yes_no(value, yes='Yes', no='No', none='No'):
if value is None:
return none
return yes if value else no

View File

@@ -101,21 +101,6 @@ class Organisation(JSONModel):
self.request_to_go_live_notes = None
self.email_branding_id = None
@property
def as_agreement_statement_for_go_live_request(self):
return '{} (organisation is {}, {}).'.format(
{
False: 'No',
None: 'Cant tell',
}.get(self.agreement_signed),
self.name,
{
True: 'a crown body',
False: 'a non-crown body',
None: 'crown status unknown',
}.get(self.crown),
)
def as_info_for_branding_request(self, fallback_domain):
return self.name or 'Cant tell (domain is {})'.format(fallback_domain)

View File

@@ -5,7 +5,7 @@ Service: {{ current_service.name }}
Organisation type: {{ current_service.organisation_type_label }}
Agreement signed:
{%- if current_service.organisation.agreement_signed %} Yes, on behalf of {{ current_service.organisation.name }}.
{%- elif current_service.organisation.name %} {{ current_service.organisation.as_agreement_statement_for_go_live_request }}
{%- elif current_service.organisation.name %} {{ current_service.organisation.agreement_signed|format_yes_no(none='Cant tell') }} (organisation is {{ current_service.organisation.name }}, {{ current_service.organisation.crown|format_yes_no(yes='a crown body', no='a non-crown body', none='crown status unknown') }}).
{%- else %} Cant tell (domain is {{ current_user.email_domain }}).
{%- endif %}
{%- if current_service.organisation.request_to_go_live_notes %} {{ current_service.organisation.request_to_go_live_notes }}{% endif %}