[PATCH 06/15] series: Add a Series model
Damien Lespiau
damien.lespiau at intel.com
Mon Oct 19 22:18:58 AEDT 2015
On Sat, Oct 10, 2015 at 12:21:15AM +0100, Finucane, Stephen wrote:
> > +class Series(models.Model):
> > + project = models.ForeignKey(Project)
> > + name = models.CharField(max_length=200, null=True, blank=False)
> > + submitter = models.ForeignKey(Person, related_name='submitters')
> > + reviewer = models.ForeignKey(User, related_name='reviewers',
> > null=True,
> > + blank=True)
> > + submitted = models.DateTimeField(default=datetime.datetime.now)
>
> Potential edge case: what happens if a series doesn't have a cover
> letter (and therefore no email to get the "submitted" time from)?
submitted is the timestamp of the row creation, disregarding if the
series has a cover letter or not. No email is getting parsed to set that
field.
> > + last_updated = models.DateTimeField(auto_now=True)
> > + # Caches the latest version so we can display it without looking at
> > the max
> > + # of all SeriesRevision.version
> > + version = models.IntegerField(default=1)
> > + # This is the number of patches of the latest version.
> > + n_patches = models.IntegerField(default=0)
> > +
> > + def __unicode__(self):
> > + return self.name
> > +
> > + def revisions(self):
> > + return SeriesRevision.objects.filter(series=self)
> > +
> > + def latest_revision(self):
> > + return self.revisions().reverse()[0]
>
> return self.revisions[-1]
Django doesn't support that.
> > +
> > + def get_absolute_url(self):
> > + return reverse('series', kwargs={ 'series': self.pk })
> > +
> > + def dump(self):
> > + print('')
> > + print('===')
> > + print('Series: %s' % self)
> > + print(' version %d' % self.version)
> > + for rev in self.revisions():
> > + print(' rev %d:' % rev.version)
> > + i = 1
> > + for patch in rev.ordered_patches():
> > + print(' patch %d:' % i)
> > + print(' subject: %s' % patch.name)
> > + print(' msgid : %s' % patch.msgid)
> > + i += 1
>
>
> No need reinventing the wheel: override the '__str__' (not the '__repr__') function instead
This is for debugging only and contains too much details to be part of __str__.
--
Damien
More information about the Patchwork
mailing list