Move ‘can’t tell’ message to 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:15:41 +01:00
parent d76dacc41e
commit eefc903b25
2 changed files with 18 additions and 19 deletions

View File

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

View File

@@ -3,10 +3,10 @@ Service: {{ current_service.name }}
--- ---
Organisation type: {{ current_service.organisation_type_label }} Organisation type: {{ current_service.organisation_type_label }}
{% if current_service.organisation.agreement_signed -%} Agreement signed:
Agreement signed: Yes, on behalf of {{ current_service.organisation.name }}. {%- if current_service.organisation.agreement_signed %} Yes, on behalf of {{ current_service.organisation.name }}.
{%- else -%} {%- elif current_service.organisation.name %} {{ current_service.organisation.as_agreement_statement_for_go_live_request }}
Agreement signed: {{ current_service.organisation.as_agreement_statement_for_go_live_request(current_user.email_domain) }} {%- else %} Cant tell (domain is {{ current_user.email_domain }}).
{%- endif %} {%- endif %}
{%- if current_service.organisation.request_to_go_live_notes %} {{ current_service.organisation.request_to_go_live_notes }}{% endif %} {%- if current_service.organisation.request_to_go_live_notes %} {{ current_service.organisation.request_to_go_live_notes }}{% endif %}
{%- if current_service.organisation.agreement_signed_by %} {%- if current_service.organisation.agreement_signed_by %}