Skip to content

Commit abbcfae

Browse files
committed
Disallow assigning others as reviewer/committer on open patches
1 parent f1329ab commit abbcfae

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)