mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-11 04:44:15 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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: 'Can’t 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 'Can’t tell (domain is {})'.format(fallback_domain)
|
||||
|
||||
|
||||
@@ -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='Can’t 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 %} Can’t 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 %}
|
||||
|
||||
Reference in New Issue
Block a user