From 8f24b2ed801da5291bb79ba9b9b4b7e43b5224cf Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 9 Jan 2019 12:38:38 -0400 Subject: [PATCH] Improve Template hash calculation Calculate the Template hash from the content actually returned. Remove the newlines as these are irrelevant for HTML. Signed-off-by: Roberto Rosario --- mayan/apps/common/classes.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mayan/apps/common/classes.py b/mayan/apps/common/classes.py index ffd4b9e626..6af4eea5b4 100644 --- a/mayan/apps/common/classes.py +++ b/mayan/apps/common/classes.py @@ -301,7 +301,9 @@ class Template(object): self.__class__._registry[name] = self def get_absolute_url(self): - return reverse('rest_api:template-detail', args=(self.name,)) + return reverse( + viewname='rest_api:template-detail', kwargs={'template_pk': self.name} + ) def render(self, request): context = { @@ -313,8 +315,10 @@ class Template(object): context=context, ).render() - self.html = result.rendered_content - self.hex_hash = hashlib.sha256(result.content).hexdigest() + content = result.rendered_content.replace('\n', '') + + self.html = content + self.hex_hash = hashlib.sha256(content).hexdigest() return self