Add API client method to count templates

When users request to go live we check stuff like:
- if they’ve added templates
- if they have email templates (then we can check their reply to
  address)

This commit adds a method to do this programatically rather than
manually.

We _could_ do this in SQL, but for page that’s used intermittently it
doesn’t feel worth the work/optimisation (and the client method is at
least in place now if we do ever need to lean on this code more
heavily).
This commit is contained in:
Chris Hill-Scott
2018-02-21 14:37:27 +00:00
parent 103a36a5da
commit 51f0320aec
2 changed files with 66 additions and 1 deletions

View File

@@ -226,6 +226,16 @@ class ServiceAPIClient(NotifyAdminAPIClient):
service_id=service_id)
return self.get(endpoint, *params)
def count_service_templates(self, service_id, template_type=None):
return len([
template for template in
self.get_service_templates(service_id)['data']
if (
not template_type
or template['template_type'] == template_type
)
])
def delete_service_template(self, service_id, template_id):
"""
Set a service template's archived flag to True