Skip to content

Commit df052e8

Browse files
authored
Disallow assigning others as reviewer/committer on open patches (#31)
Many people assign themselves to open entries as a reviewer/committer as a sort of bookmarking system for open patches they are interested in. Currently it's allowed for others to assign anyone as a reviewer/committer, thus effectively modifying people their bookmarking system. This is especially made worse because you can sign up in your profile to receive email updates from the commitfest app for patches that you are reviewer/committer of and would then thus start receiving updates for patches you might not be interested in. Assigning reviewers/committers to closed patches is still be allowed. When committing, reviewers are sometimes added by the committer to reflect the same as their Reviewed-By footer, even if those reviewers didn't explicitly sign up as a reviewer on the commitfest app for this patch. Fixes #12
1 parent 184e7f8 commit df052e8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pgcommitfest/commitfest/forms.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ def __init__(self, *args, **kwargs):
9898
u.username, u.get_full_name()
9999
)
100100

101+
# Only allow modifying reviewers and committers if the patch is closed.
102+
if (
103+
self.instance.id is None
104+
or self.instance.current_patch_on_commitfest().is_open
105+
):
106+
del self.fields["committer"]
107+
del self.fields["reviewers"]
108+
101109

102110
class NewPatchForm(PatchForm):
103111
# Put threadmsgid first

pgcommitfest/commitfest/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.contrib.auth.models import User
22
from django.db import models
3+
from django.shortcuts import get_object_or_404
34

45
from datetime import datetime
56

@@ -154,6 +155,10 @@ class Patch(models.Model, DiffableModel):
154155
def current_commitfest(self):
155156
return self.commitfests.order_by("-startdate").first()
156157

158+
def current_patch_on_commitfest(self):
159+
cf = self.current_commitfest()
160+
return get_object_or_404(PatchOnCommitFest, patch=self, commitfest=cf)
161+
157162
# Some accessors
158163
@property
159164
def authors_string(self):
@@ -258,6 +263,10 @@ def OPEN_STATUS_CHOICES(cls):
258263
def is_closed(self):
259264
return self.status not in self.OPEN_STATUSES
260265

266+
@property
267+
def is_open(self):
268+
return not self.is_closed
269+
261270
@property
262271
def statusstring(self):
263272
return [v for k, v in self._STATUS_CHOICES if k == self.status][0]

0 commit comments

Comments
 (0)