On 10/09/2016 05:25 PM, Stephen Finucane wrote: > Add a series model. This model is intentionally very minimal to allow > as much dynaminism as possible. It is expected that patches will be > migrated between series as new data is provided. > > Signed-off-by: Stephen Finucane <step...@that.guru> > ---
> diff --git a/patchwork/models.py b/patchwork/models.py > index 28e9861..4a55c1d 100644 > --- a/patchwork/models.py > +++ b/patchwork/models.py > @@ -293,7 +293,7 @@ class EmailMixin(models.Model): > class CoverLetter(Submission): > - pass > + > + @property > + def series(self): > + """Get a simple series reference. > + > + Return the last series revision that (ordered by date) that > + this submission is a member of. > + > + .. warning:: > + Be judicious in your use of this. For example, do not use it > + in list templates as doing so will result in a new query for > + each item in the list. > + """ > + # NOTE(stephenfin): We don't use 'latest()' here, as this can raise > an > + # exception if no series revisions exist > + return self.series_revisions.order_by('-date').first() I see this method both here and in the Patch class. Couldn't we just put it in the Submission class once and avoid the duplication? _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork