Skip to content

Commit a3bac59

Browse files
committed
Add a field to each patch for target version
This is particularly interesting towards the end of a cycle where it can be used to flag patches that are not intended for the current version but still needs review.
1 parent 757db07 commit a3bac59

File tree

7 files changed

+64
-3
lines changed

7 files changed

+64
-3
lines changed

pgcommitfest/commitfest/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class MailThreadAttachmentAdmin(admin.ModelAdmin):
2626
admin.site.register(Topic)
2727
admin.site.register(Patch, PatchAdmin)
2828
admin.site.register(PatchHistory)
29+
admin.site.register(TargetVersion)
2930

3031
admin.site.register(MailThread)
3132
admin.site.register(MailThreadAttachment, MailThreadAttachmentAdmin)

pgcommitfest/commitfest/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from selectable.forms.widgets import AutoCompleteSelectMultipleWidget
99

10-
from .models import Patch, MailThread, PatchOnCommitFest
10+
from .models import Patch, MailThread, PatchOnCommitFest, TargetVersion
1111
from .lookups import UserLookup
1212
from .widgets import ThreadPickWidget
1313
from .ajax import _archivesAPI
@@ -16,6 +16,7 @@
1616
class CommitFestFilterForm(forms.Form):
1717
text = forms.CharField(max_length=50, required=False)
1818
status = forms.ChoiceField(required=False)
19+
targetversion = forms.ChoiceField(required=False)
1920
author = forms.ChoiceField(required=False)
2021
reviewer = forms.ChoiceField(required=False)
2122
sortkey = forms.IntegerField(required=False)
@@ -30,6 +31,7 @@ def __init__(self, cf, *args, **kwargs):
3031

3132
q = Q(patch_author__commitfests=cf) | Q(patch_reviewer__commitfests=cf)
3233
userchoices = [(-1, '* All'), (-2, '* None'), (-3, '* Yourself')] + [(u.id, '%s %s (%s)' % (u.first_name, u.last_name, u.username)) for u in User.objects.filter(q).distinct().order_by('first_name', 'last_name')]
34+
self.fields['targetversion'] = forms.ChoiceField(choices=[('-1', '* All'), ('-2', '* None')] + [(v.id, v.version) for v in TargetVersion.objects.all()], required=False, label="Target version")
3335
self.fields['author'] = forms.ChoiceField(choices=userchoices, required=False)
3436
self.fields['reviewer'] = forms.ChoiceField(choices=userchoices, required=False)
3537

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.11.17 on 2019-02-06 19:43
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
import django.db.models.deletion
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('commitfest', '0003_withdrawn_status'),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='TargetVersion',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('version', models.CharField(max_length=8, unique=True)),
21+
],
22+
options={
23+
'ordering': ['-version', ],
24+
},
25+
),
26+
migrations.AddField(
27+
model_name='patch',
28+
name='targetversion',
29+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='commitfest.TargetVersion', verbose_name='Target version'),
30+
),
31+
]

pgcommitfest/commitfest/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ def __str__(self):
7575
return self.topic
7676

7777

78+
class TargetVersion(models.Model):
79+
version = models.CharField(max_length=8, blank=False, null=False, unique=True)
80+
81+
class Meta:
82+
ordering = ['-version', ]
83+
84+
def __str__(self):
85+
return self.version
86+
87+
7888
class Patch(models.Model, DiffableModel):
7989
name = models.CharField(max_length=500, blank=False, null=False, verbose_name='Description')
8090
topic = models.ForeignKey(Topic, blank=False, null=False)
@@ -88,6 +98,9 @@ class Patch(models.Model, DiffableModel):
8898
# If there is a git repo about this patch
8999
gitlink = models.URLField(blank=True, null=False, default='')
90100

101+
# Version targeted by this patch
102+
targetversion = models.ForeignKey(TargetVersion, blank=True, null=True, verbose_name="Target version")
103+
91104
authors = models.ManyToManyField(User, related_name='patch_author', blank=True)
92105
reviewers = models.ManyToManyField(User, related_name='patch_reviewer', blank=True)
93106

pgcommitfest/commitfest/templates/commitfest.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
6262
<tr>
6363
<th>{%if p.is_open%}<a href="#" style="color:#333333;" onclick="return sortpatches(0);">Patch</a>{%if sortkey == 0%}<div style="float:right;"><i class="glyphicon glyphicon-arrow-down"></i></div>{%endif%}{%endif%}</th>
6464
<th>Status</th>
65+
<th>Ver</th>
6566
<th>Author</th>
6667
<th>Reviewers</th>
6768
<th>Committer</th>
@@ -84,6 +85,7 @@ <h3>{{p.is_open|yesno:"Active patches,Closed patches"}}</h3>
8485
<tr>
8586
<td><a href="{{p.id}}/">{{p.name}}</a></td>
8687
<td><span class="label label-{{p.status|patchstatuslabel}}">{{p.status|patchstatusstring}}</span></td>
88+
<td>{%if p.targetversion%}<span class="label label-primary">{{p.targetversion}}</span>{%endif%}</td>
8789
<td>{{p.author_names|default:''}}</td>
8890
<td>{{p.reviewer_names|default:''}}</td>
8991
<td>{{p.committer|default:''}}</td>

pgcommitfest/commitfest/templates/patch.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
{%endfor%}
3232
</td>
3333
</tr>
34+
<tr>
35+
<th>Target version</th>
36+
<td>{%if patch.targetversion%}<span class="label label-primary">{{patch.targetversion}}</span>{%endif%}
37+
</tr>
3438
<tr>
3539
<th>Authors</th>
3640
<td>{{patch.authors_string}}</td>

pgcommitfest/commitfest/views.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ def commitfest(request, cfid):
117117
# int() failed -- so just ignore this filter
118118
pass
119119

120+
if request.GET.get('targetversion', '-1') != '-1':
121+
if request.GET['targetversion'] == '-2':
122+
whereclauses.append("targetversion_id IS NULL")
123+
else:
124+
whereparams['verid'] = int(request.GET['targetversion'])
125+
whereclauses.append("targetversion_id=%(verid)s")
126+
120127
if request.GET.get('author', '-1') != '-1':
121128
if request.GET['author'] == '-2':
122129
whereclauses.append("NOT EXISTS (SELECT 1 FROM commitfest_patch_authors cpa WHERE cpa.patch_id=p.id)")
@@ -193,7 +200,7 @@ def commitfest(request, cfid):
193200

194201
# Let's not overload the poor django ORM
195202
curs = connection.cursor()
196-
curs.execute("""SELECT p.id, p.name, poc.status, p.created, p.modified, p.lastmail, committer.username AS committer, t.topic,
203+
curs.execute("""SELECT p.id, p.name, poc.status, v.version AS targetversion, p.created, p.modified, p.lastmail, committer.username AS committer, t.topic,
197204
(poc.status=ANY(%(openstatuses)s)) AS is_open,
198205
(SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_authors cpa ON cpa.user_id=auth_user.id WHERE cpa.patch_id=p.id) AS author_names,
199206
(SELECT string_agg(first_name || ' ' || last_name || ' (' || username || ')', ', ') FROM auth_user INNER JOIN commitfest_patch_reviewers cpr ON cpr.user_id=auth_user.id WHERE cpr.patch_id=p.id) AS reviewer_names,
@@ -202,8 +209,9 @@ def commitfest(request, cfid):
202209
INNER JOIN commitfest_patchoncommitfest poc ON poc.patch_id=p.id
203210
INNER JOIN commitfest_topic t ON t.id=p.topic_id
204211
LEFT JOIN auth_user committer ON committer.id=p.committer_id
212+
LEFT JOIN commitfest_targetversion v ON p.targetversion_id=v.id
205213
WHERE poc.commitfest_id=%(cid)s {0}
206-
GROUP BY p.id, poc.id, committer.id, t.id
214+
GROUP BY p.id, poc.id, committer.id, t.id, v.version
207215
ORDER BY is_open DESC, {1}""".format(where_str, orderby_str), params)
208216
patches = [dict(zip([col[0] for col in curs.description], row)) for row in curs.fetchall()]
209217

0 commit comments

Comments
 (0)