Skip to content

Commit

Permalink
Blerg.
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticine committed Feb 9, 2012
1 parent 4f5e7ad commit 79b17f0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions apps/build/__init__.py
@@ -0,0 +1 @@
import signals
11 changes: 0 additions & 11 deletions apps/build/models/build.py
@@ -1,5 +1,4 @@
import datetime
import hashlib

from django.db import models
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -44,13 +43,3 @@ def get_absolute_url(self):
'name_slug':self.project.name_slug,
'refspec':self.target.refspec
})

def save(self, *args, **kwargs):
"""
Call save twice here so we can access the build id once it has been
created. :/
"""
super(Build, self).save(*args, **kwargs)
self.uuid = hashlib.sha224("%s:%s:%s" % (self.project, self.target,
self.id)).hexdigest()[:7]
super(Build, self).save(*args, **kwargs)
12 changes: 12 additions & 0 deletions apps/build/signals.py
@@ -0,0 +1,12 @@
import hashlib
from django.dispatch import receiver
from django.db.models.signals import post_save

from .models import Build

@receiver(post_save, sender=Build)
def set_uuid_for_build(sender, **kwargs):
if kwargs.get('created') == True:
obj = kwargs['instance']
obj.uuid = hashlib.sha224("%s:%s:%s" % (obj.project, obj.target, obj.id)).hexdigest()[:7]
obj.save()
2 changes: 0 additions & 2 deletions requirements.pip
Expand Up @@ -9,6 +9,4 @@ gunicorn==0.13.4
psycopg2==2.4.1
nose==1.1.2
behave==1.0.0
requests==0.8.3
django-piston==0.2.3
django-supervisor==0.2.4

0 comments on commit 79b17f0

Please sign in to comment.