Use service model for the copy page

The view here is rebuilding a pseudo-service object. Now that service
objects have templates it’s cleaner to use the actual service object.

Requires a small change to the `templates_by_type` method so that it can
filter by one or many template types (a user should be able to copy any
template whose type is enabled for their service, and the service
they’re copying from).
This commit is contained in:
Chris Hill-Scott
2018-10-26 16:30:37 +01:00
parent 7d57c73411
commit 526f2d7900
3 changed files with 12 additions and 13 deletions

View File

@@ -81,9 +81,11 @@ class Service():
]
def templates_by_type(self, template_type):
if isinstance(template_type, str):
template_type = [template_type]
return [
template for template in self.templates
if template_type in {'all', template['template_type']}
if set(template_type) & {'all', template['template_type']}
]
@property