On Tue, 2024-07-30 at 17:05 -0400, Adam Hassick wrote: > Adds a ManyToMany field to represent a dependency relationship between > patch series and a helper method to add dependencies. > > Signed-off-by: Adam Hassick <ahass...@iol.unh.edu>
Looks good to me. Reviewed-by: Stephen Finucane <step...@that.guru> > --- > .../migrations/0047_series_dependencies.py | 23 ++++++++++++++++ > patchwork/models.py | 26 +++++++++++++++++++ > 2 files changed, 49 insertions(+) > create mode 100644 patchwork/migrations/0047_series_dependencies.py > > diff --git a/patchwork/migrations/0047_series_dependencies.py > b/patchwork/migrations/0047_series_dependencies.py > new file mode 100644 > index 0000000..5abbcc3 > --- /dev/null > +++ b/patchwork/migrations/0047_series_dependencies.py > @@ -0,0 +1,23 @@ > +# Generated by Django 5.0.6 on 2024-06-07 02:58 > + > +from django.db import migrations, models > + > + > +class Migration(migrations.Migration): > + dependencies = [ > + ('patchwork', '0046_patch_comment_events'), > + ] > + > + operations = [ > + migrations.AddField( > + model_name='series', > + name='dependencies', > + field=models.ManyToManyField( > + blank=True, > + help_text='Optional dependencies on this patch.', > + related_name='dependents', > + related_query_name='dependent', > + to='patchwork.series', > + ), > + ), > + ] > diff --git a/patchwork/models.py b/patchwork/models.py > index 9a619bc..cb40437 100644 > --- a/patchwork/models.py > +++ b/patchwork/models.py > @@ -840,6 +840,16 @@ class Series(FilenameMixin, models.Model): > Cover, related_name='series', null=True, on_delete=models.CASCADE > ) > > + # dependencies > + dependencies = models.ManyToManyField( > + 'self', > + symmetrical=False, > + blank=True, > + help_text='Optional dependencies on this patch.', s/patch/series/ > + related_name='dependents', > + related_query_name='dependent', > + ) > + > # metadata > name = models.CharField( > max_length=255, > @@ -880,6 +890,22 @@ class Series(FilenameMixin, models.Model): > def received_all(self): > return self.total <= self.received_total > > + def add_dependencies(self, dependencies): > + """Add dependencies to this series. > + > + Helper method to add any found dependencies to this series. > + The method will filter out self and any series not from the > + same project. > + """ > + self.dependencies.add( > + *( > + dep > + for dep in dependencies > + if dep.id != self.id and dep.project == self.project > + ) > + ) > + self.save() > + > def add_cover_letter(self, cover): > """Add a cover letter to the series. > _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork