class Notification(models.Model): project = models.ForeignKey(Project, related_name='%(class)s_notifications') objects = RelatedProjectManager() class Meta: abstract = True
class Build(models.Model): project = models.ForeignKey(Project, verbose_name=_('Project'), related_name='builds') version = models.ForeignKey(Version, verbose_name=_('Version'), null=True, related_name='builds') type = models.CharField(_('Type'), max_length=55, choices=BUILD_TYPES, default='html') state = models.CharField(_('State'), max_length=55, choices=BUILD_STATE, default='finished') date = models.DateTimeField(_('Date'), auto_now_add=True) success = models.BooleanField(_('Success'), default=True) setup = models.TextField(_('Setup'), null=True, blank=True) setup_error = models.TextField(_('Setup error'), null=True, blank=True) output = models.TextField(_('Output'), default='', blank=True) error = models.TextField(_('Error'), default='', blank=True) exit_code = models.IntegerField(_('Exit code'), max_length=3, null=True, blank=True) commit = models.CharField(_('Commit'), max_length=255, null=True, blank=True) # Manager objects = RelatedProjectManager() class Meta: ordering = ['-date'] get_latest_by = 'date' def __unicode__(self): return ugettext( u"Build %(project)s for %(usernames)s (%(pk)s)" % { 'project': self.project, 'usernames': ' '.join(self.project.users.all().values_list('username', flat=True)), 'pk': self.pk, }) @models.permalink def get_absolute_url(self): return ('builds_detail', [self.project.slug, self.pk])