Refactor to reduce nesting and repetition

This commit is contained in:
Chris Hill-Scott
2018-09-21 09:13:12 +01:00
parent f29cfc0d48
commit 8bb23e09f2
2 changed files with 24 additions and 31 deletions

View File

@@ -345,6 +345,10 @@ class Service(dict):
self.id
))
@property
def needs_to_add_email_reply_to_address(self):
return self.has_email_templates and not self.has_email_reply_to_address
@property
def shouldnt_use_govuk_as_sms_sender(self):
return self.organisation_type in {'local', 'nhs'}
@@ -356,20 +360,21 @@ class Service(dict):
service_api_client.get_sms_senders(self.id)
) in {'GOVUK', 'None'}
@property
def needs_to_change_sms_sender(self):
return all((
self.has_sms_templates,
self.shouldnt_use_govuk_as_sms_sender,
self.sms_sender_is_govuk,
))
@property
def go_live_checklist_completed(self):
return all((
self.has_team_members,
self.has_templates,
any((
not self.has_email_templates,
self.has_email_reply_to_address,
)),
any((
not self.has_sms_templates,
not self.shouldnt_use_govuk_as_sms_sender,
not self.sms_sender_is_govuk,
))
not self.needs_to_add_email_reply_to_address,
not self.needs_to_change_sms_sender,
))
@property