mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
Refactor to reduce nesting and repetition
This commit is contained in:
@@ -1128,26 +1128,14 @@ def _get_request_to_go_live_tags(service, agreement_signed):
|
|||||||
if service.go_live_checklist_completed and agreement_signed:
|
if service.go_live_checklist_completed and agreement_signed:
|
||||||
return COMPLETE
|
return COMPLETE
|
||||||
|
|
||||||
yield INCOMPLETE
|
for test, tag in (
|
||||||
|
(True, ''),
|
||||||
if not service.go_live_checklist_completed:
|
(not service.go_live_checklist_completed, '_checklist'),
|
||||||
yield INCOMPLETE + '_checklist'
|
(not agreement_signed, '_mou'),
|
||||||
|
(service.needs_to_add_email_reply_to_address, '_email_reply_to'),
|
||||||
if not agreement_signed:
|
(not service.has_team_members, '_team_member'),
|
||||||
yield INCOMPLETE + '_mou'
|
(not service.has_templates, '_template_content'),
|
||||||
|
(service.needs_to_change_sms_sender, '_sms_sender'),
|
||||||
if service.has_email_templates and not service.has_email_reply_to_address:
|
|
||||||
yield INCOMPLETE + '_email_reply_to'
|
|
||||||
|
|
||||||
if not service.has_team_members:
|
|
||||||
yield INCOMPLETE + '_team_member'
|
|
||||||
|
|
||||||
if not service.has_templates:
|
|
||||||
yield INCOMPLETE + '_template_content'
|
|
||||||
|
|
||||||
if (
|
|
||||||
service.has_sms_templates and
|
|
||||||
service.shouldnt_use_govuk_as_sms_sender and
|
|
||||||
service.sms_sender_is_govuk
|
|
||||||
):
|
):
|
||||||
yield INCOMPLETE + '_sms_sender'
|
if test:
|
||||||
|
yield INCOMPLETE + tag
|
||||||
|
|||||||
@@ -345,6 +345,10 @@ class Service(dict):
|
|||||||
self.id
|
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
|
@property
|
||||||
def shouldnt_use_govuk_as_sms_sender(self):
|
def shouldnt_use_govuk_as_sms_sender(self):
|
||||||
return self.organisation_type in {'local', 'nhs'}
|
return self.organisation_type in {'local', 'nhs'}
|
||||||
@@ -356,20 +360,21 @@ class Service(dict):
|
|||||||
service_api_client.get_sms_senders(self.id)
|
service_api_client.get_sms_senders(self.id)
|
||||||
) in {'GOVUK', 'None'}
|
) 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
|
@property
|
||||||
def go_live_checklist_completed(self):
|
def go_live_checklist_completed(self):
|
||||||
return all((
|
return all((
|
||||||
self.has_team_members,
|
self.has_team_members,
|
||||||
self.has_templates,
|
self.has_templates,
|
||||||
any((
|
not self.needs_to_add_email_reply_to_address,
|
||||||
not self.has_email_templates,
|
not self.needs_to_change_sms_sender,
|
||||||
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,
|
|
||||||
))
|
|
||||||
))
|
))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Reference in New Issue
Block a user