diff options
author | Parabola <dev@list.parabolagnulinux.org> | 2011-12-05 01:29:30 +0000 |
---|---|---|
committer | Parabola <dev@list.parabolagnulinux.org> | 2011-12-05 01:29:30 +0000 |
commit | 420a9ea6ab7a912f2288b6f8e852ea2e19556ec9 (patch) | |
tree | b337b7e29cf8303d0b78b5cb165919ffc1a57c4a /releng/models.py | |
parent | 9426870d705cdc8f18b860e00da909e0e812bef7 (diff) | |
parent | 183c4d9cefa95f46c3fa3a6936f837542426eac2 (diff) |
Merge branch 'master' of /srv/git/repositories/parabolaweb
Diffstat (limited to 'releng/models.py')
-rw-r--r-- | releng/models.py | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/releng/models.py b/releng/models.py index 07ede1c5..56187766 100644 --- a/releng/models.py +++ b/releng/models.py @@ -1,6 +1,8 @@ -from datetime import datetime - +from django.core.urlresolvers import reverse from django.db import models +from django.db.models.signals import pre_save + +from main.utils import set_created_field class IsoOption(models.Model): name = models.CharField(max_length=200) @@ -8,52 +10,34 @@ class IsoOption(models.Model): def __unicode__(self): return self.name - def get_test_result(self, success): - try: - return self.test_set.filter(success=success).select_related( - 'iso').latest('iso__id').iso - except Test.DoesNotExist: - return None - - def get_last_success(self): - return self.get_test_result(True) - - def get_last_failure(self): - return self.get_test_result(False) - class Meta: abstract = True class RollbackOption(IsoOption): - def get_rollback_test_result(self, success): - try: - return self.rollback_test_set.filter(success=success).select_related( - 'iso').latest('iso__id').iso - except Test.DoesNotExist: - return None - - def get_last_rollback_success(self): - return self.get_rollback_test_result(True) - - def get_last_rollback_failure(self): - return self.get_rollback_test_result(False) - class Meta: abstract = True class Iso(models.Model): name = models.CharField(max_length=255) created = models.DateTimeField(editable=False) + removed = models.DateTimeField(null=True, blank=True, default=None) active = models.BooleanField(default=True) + def get_absolute_url(self): + return reverse('releng-results-iso', args=[self.pk]) + def __unicode__(self): return self.name + class Meta: + verbose_name = 'ISO' + class Architecture(IsoOption): pass class IsoType(IsoOption): - pass + class Meta: + verbose_name = 'ISO type' class BootType(IsoOption): pass @@ -104,14 +88,6 @@ class Test(models.Model): success = models.BooleanField() comments = models.TextField(null=True, blank=True) -def set_created_field(sender, **kwargs): - # We use this same callback for both Isos and Tests - obj = kwargs['instance'] - if not obj.created: - obj.created = datetime.utcnow() - -from django.db.models.signals import pre_save - pre_save.connect(set_created_field, sender=Iso, dispatch_uid="releng.models") pre_save.connect(set_created_field, sender=Test, |