@@ -472,15 +472,6 @@ def comment(request, patchid, what):
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 )
@@ -568,15 +559,6 @@ def status(request, patchid, status):
568559 cf = patch .current_commitfest ()
569560 poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
570561
571- if poc .is_closed :
572- # We allow modification of patches in closed CFs *only* if it's the
573- # last CF that the patch is part of. If it's part of another CF, that
574- # is later than this one, tell the user to go there instead.
575- lastcf = PatchOnCommitFest .objects .filter (patch__id = patchid ).order_by ('-commitfest__startdate' )[0 ]
576- if poc != lastcf :
577- 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!" )
578- return HttpResponseRedirect ('/%s/%s/' % (poc .commitfest .id , poc .patch .id ))
579-
580562 if status == 'review' :
581563 newstatus = PatchOnCommitFest .STATUS_REVIEW
582564 elif status == 'author' :
@@ -595,24 +577,29 @@ def status(request, patchid, status):
595577
596578 PatchHistory (patch = poc .patch , by = request .user , what = 'New status: %s' % poc .statusstring ).save_and_notify ()
597579
598- return HttpResponseRedirect ('/%s /%s/' % (poc . commitfest . id , poc .patch .id ))
580+ return HttpResponseRedirect ('/patch /%s/' % (poc .patch .id ))
599581
600582
601583@login_required
602584@transaction .atomic
603585def close (request , patchid , status ):
604586 patch = get_object_or_404 (Patch .objects .select_related (), pk = patchid )
605587 cf = patch .current_commitfest ()
606- poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
607588
608- if poc .is_closed :
609- # We allow modification of patches in closed CFs *only* if it's the
610- # last CF that the patch is part of. If it's part of another CF, that
611- # is later than this one, tell the user to go there instead.
612- lastcf = PatchOnCommitFest .objects .filter (patch__id = patchid ).order_by ('-commitfest__startdate' )[0 ]
613- if poc != lastcf :
614- 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!" )
615- return HttpResponseRedirect ('/%s/%s/' % (poc .commitfest .id , poc .patch .id ))
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 )
616603
617604 poc .leavedate = datetime .now ()
618605
0 commit comments