Skip to content

Commit 5a9b82a

Browse files
authored
Merge branch 'master' into jbrazeal/dropdowns
2 parents c894ea2 + 27dddf5 commit 5a9b82a

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

Diff for: pgcommitfest/commitfest/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ class Patch(models.Model, DiffableModel):
122122
'reviewers': 'reviewers_string',
123123
}
124124

125+
def current_commitfest(self):
126+
return self.commitfests.order_by('-startdate').first()
127+
125128
# Some accessors
126129
@property
127130
def authors_string(self):

Diff for: pgcommitfest/commitfest/views.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ def patch(request, patchid):
374374

375375
@login_required
376376
@transaction.atomic
377-
def patchform(request, cfid, patchid):
378-
cf = get_object_or_404(CommitFest, pk=cfid)
379-
patch = get_object_or_404(Patch, pk=patchid, commitfests=cf)
377+
def patchform(request, patchid):
378+
patch = get_object_or_404(Patch, pk=patchid)
379+
cf = patch.current_commitfest()
380380

381381
prevreviewers = list(patch.reviewers.all())
382382
prevauthors = list(patch.authors.all())
@@ -466,9 +466,9 @@ def _review_status_string(reviewstatus):
466466

467467
@login_required
468468
@transaction.atomic
469-
def comment(request, cfid, patchid, what):
470-
cf = get_object_or_404(CommitFest, pk=cfid)
469+
def comment(request, patchid, what):
471470
patch = get_object_or_404(Patch, pk=patchid)
471+
cf = patch.current_commitfest()
472472
poc = get_object_or_404(PatchOnCommitFest, patch=patch, commitfest=cf)
473473
is_review = (what == 'review')
474474

@@ -563,8 +563,10 @@ def comment(request, cfid, patchid, what):
563563

564564
@login_required
565565
@transaction.atomic
566-
def status(request, cfid, patchid, status):
567-
poc = get_object_or_404(PatchOnCommitFest.objects.select_related(), commitfest__id=cfid, patch__id=patchid)
566+
def status(request, patchid, status):
567+
patch = get_object_or_404(Patch.objects.select_related(), pk=patchid)
568+
cf = patch.current_commitfest()
569+
poc = get_object_or_404(PatchOnCommitFest.objects.select_related(), commitfest__id=cf.id, patch__id=patchid)
568570

569571
if poc.is_closed:
570572
# We allow modification of patches in closed CFs *only* if it's the
@@ -598,8 +600,10 @@ def status(request, cfid, patchid, status):
598600

599601
@login_required
600602
@transaction.atomic
601-
def close(request, cfid, patchid, status):
602-
poc = get_object_or_404(PatchOnCommitFest.objects.select_related(), commitfest__id=cfid, patch__id=patchid)
603+
def close(request, patchid, status):
604+
patch = get_object_or_404(Patch.objects.select_related(), pk=patchid)
605+
cf = patch.current_commitfest()
606+
poc = get_object_or_404(PatchOnCommitFest.objects.select_related(), commitfest__id=cf.id, patch__id=patchid)
603607

604608
if poc.is_closed:
605609
# We allow modification of patches in closed CFs *only* if it's the
@@ -696,8 +700,7 @@ def close(request, cfid, patchid, status):
696700

697701
@login_required
698702
@transaction.atomic
699-
def reviewer(request, cfid, patchid, status):
700-
get_object_or_404(CommitFest, pk=cfid)
703+
def reviewer(request, patchid, status):
701704
patch = get_object_or_404(Patch, pk=patchid)
702705

703706
is_reviewer = request.user in patch.reviewers.all()
@@ -716,7 +719,6 @@ def reviewer(request, cfid, patchid, status):
716719
@login_required
717720
@transaction.atomic
718721
def committer(request, cfid, patchid, status):
719-
get_object_or_404(CommitFest, pk=cfid)
720722
patch = get_object_or_404(Patch, pk=patchid)
721723

722724
committer = list(Committer.objects.filter(user=request.user, active=True))
@@ -741,8 +743,7 @@ def committer(request, cfid, patchid, status):
741743

742744
@login_required
743745
@transaction.atomic
744-
def subscribe(request, cfid, patchid, sub):
745-
get_object_or_404(CommitFest, pk=cfid)
746+
def subscribe(request, patchid, sub):
746747
patch = get_object_or_404(Patch, pk=patchid)
747748

748749
if sub == 'un':
@@ -755,6 +756,12 @@ def subscribe(request, cfid, patchid, sub):
755756
return HttpResponseRedirect("../")
756757

757758

759+
def send_patch_email(request, patchid):
760+
patch = get_object_or_404(Patch, pk=patchid)
761+
cf = patch.current_commitfest()
762+
return send_email(request, cf.id)
763+
764+
758765
@login_required
759766
@transaction.atomic
760767
def send_email(request, cfid):

Diff for: pgcommitfest/urls.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
re_path(r'^(\d+)/$', views.commitfest),
2020
re_path(r'^(open|inprogress|current)/(.*)$', views.redir),
2121
re_path(r'^(?P<cfid>\d+)/activity(?P<rss>\.rss)?/$', views.activity),
22-
re_path(r'^patch/(\d+)/$', views.patch),
2322
re_path(r'^(\d+)/(\d+)/$', views.patch_legacy_redirect),
24-
re_path(r'^(\d+)/(\d+)/edit/$', views.patchform),
23+
re_path(r'^patch/(\d+)/$', views.patch),
24+
re_path(r'^patch/(\d+)/edit/$', views.patchform),
2525
re_path(r'^(\d+)/new/$', views.newpatch),
26-
re_path(r'^(\d+)/(\d+)/status/(review|author|committer)/$', views.status),
27-
re_path(r'^(\d+)/(\d+)/close/(reject|withdrawn|feedback|committed|next)/$', views.close),
28-
re_path(r'^(\d+)/(\d+)/reviewer/(become|remove)/$', views.reviewer),
29-
re_path(r'^(\d+)/(\d+)/committer/(become|remove)/$', views.committer),
30-
re_path(r'^(\d+)/(\d+)/(un)?subscribe/$', views.subscribe),
31-
re_path(r'^(\d+)/(\d+)/(comment|review)/', views.comment),
26+
re_path(r'^patch/(\d+)/status/(review|author|committer)/$', views.status),
27+
re_path(r'^patch/(\d+)/close/(reject|withdrawn|feedback|committed|next)/$', views.close),
28+
re_path(r'^patch/(\d+)/reviewer/(become|remove)/$', views.reviewer),
29+
re_path(r'^patch/(\d+)/committer/(become|remove)/$', views.committer),
30+
re_path(r'^patch/(\d+)/(un)?subscribe/$', views.subscribe),
31+
re_path(r'^patch/(\d+)/(comment|review)/', views.comment),
3232
re_path(r'^(\d+)/send_email/$', views.send_email),
33-
re_path(r'^(\d+)/\d+/send_email/$', views.send_email),
33+
re_path(r'^patch/(\d+)/send_email/$', views.send_patch_email),
3434
re_path(r'^(\d+)/reports/authorstats/$', reports.authorstats),
3535
re_path(r'^search/$', views.global_search),
3636
re_path(r'^ajax/(\w+)/$', ajax.main),

0 commit comments

Comments
 (0)