Skip to content

Commit 6526e32

Browse files
models: Add fields for series sequences
* Add ManyToMany field to represent a new series that will supersed another, or is superseded by another. * Add show_series_versions to enable this feature in a project Signed-off-by: Victor Accarini <[email protected]>
1 parent 1c3e4d4 commit 6526e32

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Generated by Django 5.1.4 on 2025-03-20 01:28
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
('patchwork', '0048_series_dependencies'),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name='series',
14+
name='supersedes',
15+
field=models.ManyToManyField(
16+
blank=True,
17+
help_text='Previous versions of this patch.',
18+
related_name='superseded',
19+
to='patchwork.series',
20+
),
21+
),
22+
migrations.AddField(
23+
model_name='project',
24+
name='show_series_versions',
25+
field=models.BooleanField(
26+
default=False,
27+
help_text='Enable parsing series previous versions on patches '
28+
'and cover letters.',
29+
),
30+
),
31+
]

patchwork/models.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ class Project(models.Model):
104104
default=False,
105105
help_text='Enable dependency tracking for patches and cover letters.',
106106
)
107+
show_series_versions = models.BooleanField(
108+
default=False,
109+
help_text='Enable parsing series previous versions on patches and '
110+
'cover letters.',
111+
)
107112
use_tags = models.BooleanField(default=True)
108113

109114
def is_editable(self, user):
@@ -858,6 +863,15 @@ class Series(FilenameMixin, models.Model):
858863
related_query_name='dependent',
859864
)
860865

866+
# versioning
867+
supersedes = models.ManyToManyField(
868+
'self',
869+
symmetrical=False,
870+
blank=True,
871+
help_text='Previous versions of this patch.',
872+
related_name='superseded',
873+
)
874+
861875
# metadata
862876
name = models.CharField(
863877
max_length=255,
@@ -889,6 +903,15 @@ def _format_name(obj):
889903
return match.group(2)
890904
return obj.name.strip()
891905

906+
def is_editable(self, user):
907+
if not user.is_authenticated:
908+
return False
909+
910+
if user.is_superuser or user == self.submitter.user:
911+
return True
912+
913+
return self.project.is_editable(user)
914+
892915
@property
893916
def received_total(self):
894917
return self.patches.count()

0 commit comments

Comments
 (0)