@@ -472,15 +472,6 @@ def comment(request, patchid, what):
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 )
@@ -568,15 +559,6 @@ def status(request, patchid, status):
568
559
cf = patch .current_commitfest ()
569
560
poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
570
561
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
-
580
562
if status == 'review' :
581
563
newstatus = PatchOnCommitFest .STATUS_REVIEW
582
564
elif status == 'author' :
@@ -595,24 +577,29 @@ def status(request, patchid, status):
595
577
596
578
PatchHistory (patch = poc .patch , by = request .user , what = 'New status: %s' % poc .statusstring ).save_and_notify ()
597
579
598
- return HttpResponseRedirect ('/%s /%s/' % (poc . commitfest . id , poc .patch .id ))
580
+ return HttpResponseRedirect ('/patch /%s/' % (poc .patch .id ))
599
581
600
582
601
583
@login_required
602
584
@transaction .atomic
603
585
def close (request , patchid , status ):
604
586
patch = get_object_or_404 (Patch .objects .select_related (), pk = patchid )
605
587
cf = patch .current_commitfest ()
606
- poc = get_object_or_404 (PatchOnCommitFest .objects .select_related (), commitfest__id = cf .id , patch__id = patchid )
607
588
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 )
616
603
617
604
poc .leavedate = datetime .now ()
618
605
0 commit comments