@@ -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,21 +466,12 @@ 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
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-
484475 if request .method == 'POST' :
485476 try :
486477 form = CommentForm (patch , poc , is_review , data = request .POST )
@@ -563,17 +554,10 @@ def comment(request, cfid, patchid, what):
563554
564555@login_required
565556@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 )
577561
578562 if status == 'review' :
579563 newstatus = PatchOnCommitFest .STATUS_REVIEW
@@ -593,22 +577,29 @@ def status(request, cfid, patchid, status):
593577
594578 PatchHistory (patch = poc .patch , by = request .user , what = 'New status: %s' % poc .statusstring ).save_and_notify ()
595579
596- return HttpResponseRedirect ('/%s /%s/' % (poc . commitfest . id , poc .patch .id ))
580+ return HttpResponseRedirect ('/patch /%s/' % (poc .patch .id ))
597581
598582
599583@login_required
600584@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 )
612603
613604 poc .leavedate = datetime .now ()
614605
@@ -696,8 +687,7 @@ def close(request, cfid, patchid, status):
696687
697688@login_required
698689@transaction .atomic
699- def reviewer (request , cfid , patchid , status ):
700- get_object_or_404 (CommitFest , pk = cfid )
690+ def reviewer (request , patchid , status ):
701691 patch = get_object_or_404 (Patch , pk = patchid )
702692
703693 is_reviewer = request .user in patch .reviewers .all ()
@@ -716,7 +706,6 @@ def reviewer(request, cfid, patchid, status):
716706@login_required
717707@transaction .atomic
718708def committer (request , cfid , patchid , status ):
719- get_object_or_404 (CommitFest , pk = cfid )
720709 patch = get_object_or_404 (Patch , pk = patchid )
721710
722711 committer = list (Committer .objects .filter (user = request .user , active = True ))
@@ -741,8 +730,7 @@ def committer(request, cfid, patchid, status):
741730
742731@login_required
743732@transaction .atomic
744- def subscribe (request , cfid , patchid , sub ):
745- get_object_or_404 (CommitFest , pk = cfid )
733+ def subscribe (request , patchid , sub ):
746734 patch = get_object_or_404 (Patch , pk = patchid )
747735
748736 if sub == 'un' :
@@ -755,6 +743,12 @@ def subscribe(request, cfid, patchid, sub):
755743 return HttpResponseRedirect ("../" )
756744
757745
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+
758752@login_required
759753@transaction .atomic
760754def send_email (request , cfid ):
0 commit comments