Skip to content

Commit

Permalink
models: Add 'related_series' field to Series model
Browse files Browse the repository at this point in the history
Closes getpatchwork#506

Signed-off-by: andrepapoti <[email protected]>
  • Loading branch information
andrepapoti committed Apr 10, 2024
1 parent 7494873 commit f44254c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions patchwork/migrations/0047_series_related_series.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
8 changes: 8 additions & 0 deletions patchwork/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f44254c

Please sign in to comment.