Skip to content

Commit f44254c

Browse files
committed
models: Add 'related_series' field to Series model
Closes getpatchwork#506 Signed-off-by: andrepapoti <[email protected]>
1 parent 7494873 commit f44254c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.0.2 on 2024-03-14 16:20
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
('patchwork', '0046_patch_comment_events'),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name='series',
14+
name='related_series',
15+
field=models.ManyToManyField(to='patchwork.series'),
16+
),
17+
]

patchwork/models.py

+8
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ class Series(FilenameMixin, models.Model):
848848
help_text='An optional name to associate with '
849849
'the series, e.g. "John\'s PCI series".',
850850
)
851+
related_series = models.ManyToManyField('self')
851852
date = models.DateTimeField()
852853
submitter = models.ForeignKey(Person, on_delete=models.CASCADE)
853854
version = models.IntegerField(
@@ -934,6 +935,13 @@ def add_patch(self, patch, number):
934935

935936
return patch
936937

938+
def is_editable(self, user):
939+
if not user.is_authenticated:
940+
return False
941+
942+
person = Person.objects.get(user=user)
943+
return person == self.submitter
944+
937945
def get_absolute_url(self):
938946
# TODO(stephenfin): We really need a proper series view
939947
return reverse(

0 commit comments

Comments
 (0)