[PATCH 06/15] series: Add a Series model
Finucane, Stephen
stephen.finucane at intel.com
Tue Oct 20 11:19:26 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.
Right you are: my mistake.
> > > +
> > > + 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__.
Ehh, we could get away with it would be inconsistent with the rest of the '__str__' functions in that file. Given this (and other replies):
Acked-by: Stephen Finucane <stephen.finucane at intel.com.
More information about the Patchwork
mailing list