From 0521d8b2e26242fa3a161df50b3f61b9a05ae0dd Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Tue, 9 Sep 2008 17:26:38 +1000 Subject: Hook-up hashing infrastructure Signed-off-by: Jeremy Kerr --- apps/patchwork/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apps/patchwork/models.py') diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py index fb2ccc7..f354acb 100644 --- a/apps/patchwork/models.py +++ b/apps/patchwork/models.py @@ -22,6 +22,7 @@ from django.contrib.auth.models import User from django.core.urlresolvers import reverse from django.contrib.sites.models import Site from django.conf import settings +from patchwork.parser import hash_patch import django.oldforms as oldforms import re @@ -223,7 +224,7 @@ class Patch(models.Model): headers = models.TextField(blank = True) content = models.TextField() commit_ref = models.CharField(max_length=255, null = True, blank = True) - hash = HashField() + hash = HashField(null = True) def __str__(self): return self.name @@ -236,8 +237,10 @@ class Patch(models.Model): s = self.state except: self.state = State.objects.get(ordering = 0) - if hash is None: - print "no hash" + + if self.hash is None: + self.hash = hash_patch(self.content).digest() + super(Patch, self).save() def is_editable(self, user): -- cgit v1.2.3