mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-15 01:23:25 -05:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user