Add TemplateHistory.get_link method

Notifications.serialize calls `Notifications.template.get_link`, so
we need TemplateHistory objects to generate their API URLs.

This generates a link to the `/v2/` version of the endpoint.
This commit is contained in:
Alexey Bezhan
2017-11-09 14:48:27 +00:00
parent c62f2a3f7c
commit 79d417f13b
2 changed files with 9 additions and 1 deletions

View File

@@ -645,6 +645,14 @@ class TemplateHistory(db.Model):
nullable=False,
default=NORMAL)
def get_link(self):
return url_for(
"v2_template.get_template_by_id",
template_id=self.id,
version=self.version,
_external=True
)
def _as_utils_template(self):
return Template._as_utils_template(self)