Refactor summaries into model

This lets us encapsulate some of the logic that’s currently cluttering
up the view/template layer.
This commit is contained in:
Chris Hill-Scott
2020-02-12 14:03:51 +00:00
parent 5ba5ee2502
commit 74e70ed8bc
4 changed files with 18 additions and 13 deletions

View File

@@ -480,6 +480,12 @@ class Service(JSONModel):
def has_inbound_number(self):
return bool(self.inbound_number)
@cached_property
def inbound_sms_summary(self):
if not self.has_permission('inbound_sms'):
return None
return service_api_client.get_inbound_sms_summary(self.id)
@cached_property
def all_template_folders(self):
return sorted(
@@ -660,3 +666,7 @@ class Service(JSONModel):
):
if test:
yield BASE + '_incomplete' + tag
@cached_property
def returned_letter_summary(self):
return service_api_client.get_returned_letter_summary(self.id)