@@ -374,9 +374,9 @@ def patch(request, patchid):
374
374
375
375
@login_required
376
376
@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 ( )
380
380
381
381
prevreviewers = list (patch .reviewers .all ())
382
382
prevauthors = list (patch .authors .all ())
@@ -466,21 +466,12 @@ def _review_status_string(reviewstatus):
466
466
467
467
@login_required
468
468
@transaction .atomic
469
- def comment (request , cfid , patchid , what ):
470
- cf = get_object_or_404 (CommitFest , pk = cfid )
469
+ def comment (request , patchid , what ):
471
470
patch = get_object_or_404 (Patch , pk = patchid )
471
+ cf = patch .current_commitfest ()
472
472
poc = get_object_or_404 (PatchOnCommitFest , patch = patch , commitfest = cf )
473
473
is_review = (what == 'review' )
474
474
475
- if poc .is_closed :
476
- # We allow modification of patches in closed CFs *only* if it's the
477
- # last CF that the patch is part of. If it's part of another CF, that
478
- # is later than this one, tell the user to go there instead.
479
- lastcf = PatchOnCommitFest .objects .filter (patch = patch ).order_by ('-commitfest__startdate' )[0 ]
480
- if poc != lastcf :
481
- messages .add_message (request , messages .INFO , "The status of this patch cannot be changed in this commitfest. You must modify it in the one where it's open!" )
482
- return HttpResponseRedirect ('..' )
483
-
484
475
if request .method == 'POST' :
485
476
try :
486
477
form = CommentForm (patch , poc , is_review , data = request .POST )
@@ -563,17 +554,10 @@ def comment(request, cfid, patchid, what):
563
554
564
555
@login_required
565
556
@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 )
568
-
569
- if poc .is_closed :
570
- # We allow modification of patches in closed CFs *only* if it's the
571
- # last CF that the patch is part of. If it's part of another CF, that
572
- # is later than this one, tell the user to go there instead.
573
- lastcf = PatchOnCommitFest .objects .filter (patch__id = patchid ).order_by ('-commitfest__startdate' )[0 ]
574
- if poc != lastcf :
575
- messages .add_message (request , messages .INFO , "The status of this patch cannot be changed in this commitfest. You must modify it in the one where it's open!" )
576
- return HttpResponseRedirect ('/%s/%s/' % (poc .commitfest .id , poc .patch .id ))
557
+ def status (request , patchid , status ):
558
+ patch = get_object_or_404 (Patch .objects .select_related (), pk = patchid )
559
+ cf = patch .current_commitfest ()
560
+ poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
577
561
578
562
if status == 'review' :
579
563
newstatus = PatchOnCommitFest .STATUS_REVIEW
@@ -593,22 +577,29 @@ def status(request, cfid, patchid, status):
593
577
594
578
PatchHistory (patch = poc .patch , by = request .user , what = 'New status: %s' % poc .statusstring ).save_and_notify ()
595
579
596
- return HttpResponseRedirect ('/%s /%s/' % (poc . commitfest . id , poc .patch .id ))
580
+ return HttpResponseRedirect ('/patch /%s/' % (poc .patch .id ))
597
581
598
582
599
583
@login_required
600
584
@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
-
604
- if poc .is_closed :
605
- # We allow modification of patches in closed CFs *only* if it's the
606
- # last CF that the patch is part of. If it's part of another CF, that
607
- # is later than this one, tell the user to go there instead.
608
- lastcf = PatchOnCommitFest .objects .filter (patch__id = patchid ).order_by ('-commitfest__startdate' )[0 ]
609
- if poc != lastcf :
610
- messages .add_message (request , messages .INFO , "The status of this patch cannot be changed in this commitfest. You must modify it in the one where it's open!" )
611
- return HttpResponseRedirect ('/%s/%s/' % (poc .commitfest .id , poc .patch .id ))
585
+ def close (request , patchid , status ):
586
+ patch = get_object_or_404 (Patch .objects .select_related (), pk = patchid )
587
+ cf = patch .current_commitfest ()
588
+
589
+ try :
590
+ request_cfid = int (request .GET .get ('cfid' , '' ))
591
+ except ValueError :
592
+ # int() failed, ignore
593
+ request_cfid = None
594
+
595
+ if request_cfid is not None and request_cfid != cf .id :
596
+ # The cfid parameter is only added to the /next/ link. That's the only
597
+ # close operation where two people pressing the button at the same time
598
+ # can have unintended effects.
599
+ messages .error (request , "The patch was moved to a new commitfest by someone else. Please double check if you still want to retry this operation." )
600
+ return HttpResponseRedirect ('/%s/%s/' % (cf .id , patch .id ))
601
+
602
+ poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
612
603
613
604
poc .leavedate = datetime .now ()
614
605
@@ -696,8 +687,7 @@ def close(request, cfid, patchid, status):
696
687
697
688
@login_required
698
689
@transaction .atomic
699
- def reviewer (request , cfid , patchid , status ):
700
- get_object_or_404 (CommitFest , pk = cfid )
690
+ def reviewer (request , patchid , status ):
701
691
patch = get_object_or_404 (Patch , pk = patchid )
702
692
703
693
is_reviewer = request .user in patch .reviewers .all ()
@@ -716,7 +706,6 @@ def reviewer(request, cfid, patchid, status):
716
706
@login_required
717
707
@transaction .atomic
718
708
def committer (request , cfid , patchid , status ):
719
- get_object_or_404 (CommitFest , pk = cfid )
720
709
patch = get_object_or_404 (Patch , pk = patchid )
721
710
722
711
committer = list (Committer .objects .filter (user = request .user , active = True ))
@@ -741,8 +730,7 @@ def committer(request, cfid, patchid, status):
741
730
742
731
@login_required
743
732
@transaction .atomic
744
- def subscribe (request , cfid , patchid , sub ):
745
- get_object_or_404 (CommitFest , pk = cfid )
733
+ def subscribe (request , patchid , sub ):
746
734
patch = get_object_or_404 (Patch , pk = patchid )
747
735
748
736
if sub == 'un' :
@@ -755,6 +743,12 @@ def subscribe(request, cfid, patchid, sub):
755
743
return HttpResponseRedirect ("../" )
756
744
757
745
746
+ def send_patch_email (request , patchid ):
747
+ patch = get_object_or_404 (Patch , pk = patchid )
748
+ cf = patch .current_commitfest ()
749
+ return send_email (request , cf .id )
750
+
751
+
758
752
@login_required
759
753
@transaction .atomic
760
754
def send_email (request , cfid ):
0 commit comments