[PATCH v1 2/9] models: Add field for series dependencies
Adam Hassick
ahassick at iol.unh.edu
Tue Jun 18 08:18:48 AEST 2024
Add a ManyToMany field to represent a dependency relationship between
patch series.
Signed-off-by: Adam Hassick <ahassick at iol.unh.edu>
---
patchwork/models.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/patchwork/models.py b/patchwork/models.py
index 9a619bc..6f6a32d 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.',
+ related_name='dependents',
+ related_query_name='dependent',
+ )
+
# metadata
name = models.CharField(
max_length=255,
@@ -880,6 +890,13 @@ class Series(FilenameMixin, models.Model):
def received_all(self):
return self.total <= self.received_total
+ def add_dependencies(self, dependencies):
+ # for dependency in dependencies:
+ # dependency.dependents.add(self)
+ # dependency.save()
+ self.dependencies.add(*dependencies)
+ self.save()
+
def add_cover_letter(self, cover):
"""Add a cover letter to the series.
--
2.45.2
More information about the Patchwork
mailing list