From f44254c92da61c43d4ebbc8584f644e47197ddc7 Mon Sep 17 00:00:00 2001 From: andrepapoti Date: Mon, 18 Mar 2024 11:34:26 -0300 Subject: [PATCH] models: Add 'related_series' field to Series model Closes #506 Signed-off-by: andrepapoti --- .../migrations/0047_series_related_series.py | 17 +++++++++++++++++ patchwork/models.py | 8 ++++++++ 2 files changed, 25 insertions(+) create mode 100644 patchwork/migrations/0047_series_related_series.py diff --git a/patchwork/migrations/0047_series_related_series.py b/patchwork/migrations/0047_series_related_series.py new file mode 100644 index 00000000..df8034c7 --- /dev/null +++ b/patchwork/migrations/0047_series_related_series.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.2 on 2024-03-14 16:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('patchwork', '0046_patch_comment_events'), + ] + + operations = [ + migrations.AddField( + model_name='series', + name='related_series', + field=models.ManyToManyField(to='patchwork.series'), + ), + ] diff --git a/patchwork/models.py b/patchwork/models.py index 9a619bc5..b93eb996 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -848,6 +848,7 @@ class Series(FilenameMixin, models.Model): help_text='An optional name to associate with ' 'the series, e.g. "John\'s PCI series".', ) + related_series = models.ManyToManyField('self') date = models.DateTimeField() submitter = models.ForeignKey(Person, on_delete=models.CASCADE) version = models.IntegerField( @@ -934,6 +935,13 @@ def add_patch(self, patch, number): return patch + def is_editable(self, user): + if not user.is_authenticated: + return False + + person = Person.objects.get(user=user) + return person == self.submitter + def get_absolute_url(self): # TODO(stephenfin): We really need a proper series view return reverse(