@@ -189,7 +189,9 @@ def current_patch_on_commitfest(self):
189
189
# The unique partial index poc_enforce_maxoneoutcome_idx stores the PoC
190
190
# No caching here (inside the instance) since the caller should just need
191
191
# the PoC once per request.
192
- return get_object_or_404 (PatchOnCommitFest , Q (patch = self ) & ~ Q (status = PatchOnCommitFest .STATUS_NEXT ))
192
+ return get_object_or_404 (
193
+ PatchOnCommitFest , Q (patch = self ) & ~ Q (status = PatchOnCommitFest .STATUS_NEXT )
194
+ )
193
195
194
196
# Some accessors
195
197
@property
@@ -560,9 +562,10 @@ class CfbotTask(models.Model):
560
562
# the workflow this application is built for. These elements exist
561
563
# independent of what the user is presently seeing on their page.
562
564
class Workflow (models .Model ):
563
-
564
565
def get_poc_for_patchid_or_404 (patchid ):
565
- return get_object_or_404 (Patch .objects .select_related (), pk = patchid ).current_patch_on_commitfest ()
566
+ return get_object_or_404 (
567
+ Patch .objects .select_related (), pk = patchid
568
+ ).current_patch_on_commitfest ()
566
569
567
570
# At most a single Open CommitFest is allowed and this function returns it.
568
571
def open_cf ():
@@ -603,9 +606,8 @@ def isCommitter(user, patch):
603
606
is_committer = is_this_committer = False
604
607
return is_committer , is_this_committer , all_committers
605
608
606
-
607
609
def getCommitfest (cfid ):
608
- if ( cfid is None or cfid == "" ) :
610
+ if cfid is None or cfid == "" :
609
611
return None
610
612
try :
611
613
int_cfid = int (cfid )
@@ -624,7 +626,7 @@ def createNewPOC(patch, commitfest, initial_status, by_user):
624
626
poc , created = PatchOnCommitFest .objects .update_or_create (
625
627
patch = patch ,
626
628
commitfest = commitfest ,
627
- defaults = dict (
629
+ defaults = dict (
628
630
enterdate = datetime .now (),
629
631
status = initial_status ,
630
632
leavedate = None ,
@@ -635,10 +637,9 @@ def createNewPOC(patch, commitfest, initial_status, by_user):
635
637
poc .save ()
636
638
637
639
PatchHistory (
638
- patch = poc .patch , by = by_user ,
639
- what = "{} in {}" .format (
640
- poc .statusstring ,
641
- commitfest .name )
640
+ patch = poc .patch ,
641
+ by = by_user ,
642
+ what = "{} in {}" .format (poc .statusstring , commitfest .name ),
642
643
).save_and_notify ()
643
644
644
645
return poc
@@ -659,16 +660,9 @@ def transitionPatch(poc, target_cf, by_user):
659
660
# not allowed to change non-current commitfest status
660
661
# and once the new POC is created it becomes current.
661
662
662
- Workflow .updatePOCStatus (
663
- poc ,
664
- PatchOnCommitFest .STATUS_NEXT ,
665
- by_user )
663
+ Workflow .updatePOCStatus (poc , PatchOnCommitFest .STATUS_NEXT , by_user )
666
664
667
- new_poc = Workflow .createNewPOC (
668
- poc .patch ,
669
- target_cf ,
670
- existing_status ,
671
- by_user )
665
+ new_poc = Workflow .createNewPOC (poc .patch , target_cf , existing_status , by_user )
672
666
673
667
return new_poc
674
668
@@ -702,7 +696,7 @@ def userCanTransitionPatch(poc, target_cf, user):
702
696
# Prevent users from moving closed patches, or moving open ones to
703
697
# non-open, non-future commitfests. The else clause should be a
704
698
# can't happen.
705
- if ( poc .is_open and (target_cf .isopen or target_cf .isfuture ) ):
699
+ if poc .is_open and (target_cf .isopen or target_cf .isfuture ):
706
700
pass
707
701
else :
708
702
# Default deny policy basis
@@ -723,7 +717,10 @@ def userCanChangePOCStatus(poc, new_status, user):
723
717
# We want commits to happen from, usually, In Progress commitfests,
724
718
# or Open ones for exempt patches. We accept Future ones too just because
725
719
# they do represent a proper, if non-current, Commitfest.
726
- if poc .commitfest .id == CommitFest .STATUS_PARKED and new_status == PatchOnCommitFest .STATUS_COMMITTED :
720
+ if (
721
+ poc .commitfest .id == CommitFest .STATUS_PARKED
722
+ and new_status == PatchOnCommitFest .STATUS_COMMITTED
723
+ ):
727
724
raise Exception ("Cannot change status to committed in a parked commitfest." )
728
725
729
726
# We trust privileged users to make informed choices
@@ -743,7 +740,10 @@ def userCanChangePOCStatus(poc, new_status, user):
743
740
if new_status == PatchOnCommitFest .STATUS_RETURNED and not is_committer :
744
741
raise Exception ("Only a committer can set status to returned." )
745
742
746
- if new_status == PatchOnCommitFest .STATUS_WITHDRAWN and not user in poc .patch .authors .all ():
743
+ if (
744
+ new_status == PatchOnCommitFest .STATUS_WITHDRAWN
745
+ and user not in poc .patch .authors .all ()
746
+ ):
747
747
raise Exception ("Only the author can set status to withdrawn." )
748
748
749
749
# Prevent users from modifying closed patches
@@ -753,13 +753,12 @@ def userCanChangePOCStatus(poc, new_status, user):
753
753
else :
754
754
raise Exception ("Cannot change status of closed patch." )
755
755
756
-
757
756
# Update the status of a PoC
758
757
# Returns True if the status was changed, False for a same-status no-op.
759
758
# Creates history and notifies as a side-effect.
760
759
def updatePOCStatus (poc , new_status , by_user ):
761
760
# XXX Workflow disallows this no-op but not quite ready to enforce it.
762
- if ( poc .status == new_status ) :
761
+ if poc .status == new_status :
763
762
return False
764
763
765
764
Workflow .userCanChangePOCStatus (poc , new_status , by_user )
@@ -770,11 +769,12 @@ def updatePOCStatus(poc, new_status, by_user):
770
769
poc .patch .save ()
771
770
poc .save ()
772
771
PatchHistory (
773
- patch = poc .patch , by = by_user ,
772
+ patch = poc .patch ,
773
+ by = by_user ,
774
774
what = "{} in {}" .format (
775
775
poc .statusstring ,
776
776
poc .commitfest .name ,
777
- ),
777
+ ),
778
778
).save_and_notify ()
779
779
780
780
return True
@@ -783,7 +783,7 @@ def updatePOCStatus(poc, new_status, by_user):
783
783
# Returns True if the committer was changed, False for a same-committer no-op.
784
784
# Creates history and notifies as a side-effect.
785
785
def setCommitter (poc , committer , by_user ):
786
- if ( poc .patch .committer == committer ) :
786
+ if poc .patch .committer == committer :
787
787
return False
788
788
789
789
prevcommitter = poc .patch .committer
@@ -793,14 +793,21 @@ def setCommitter(poc, committer, by_user):
793
793
poc .save ()
794
794
795
795
if committer is None :
796
- msg = "Removed {} as committer in {}" .format (prevcommitter .fullname , poc .commitfest .name )
796
+ msg = "Removed {} as committer in {}" .format (
797
+ prevcommitter .fullname , poc .commitfest .name
798
+ )
797
799
elif prevcommitter is None :
798
- msg = "Set {} as committer in {}" .format (poc .patch .committer .fullname , poc .commitfest .name )
800
+ msg = "Set {} as committer in {}" .format (
801
+ poc .patch .committer .fullname , poc .commitfest .name
802
+ )
799
803
else :
800
- msg = "Changed to {} as committer in {}" .format (poc .patch .committer .fullname , poc .commitfest .name )
804
+ msg = "Changed to {} as committer in {}" .format (
805
+ poc .patch .committer .fullname , poc .commitfest .name
806
+ )
801
807
802
808
PatchHistory (
803
- patch = poc .patch , by = by_user ,
809
+ patch = poc .patch ,
810
+ by = by_user ,
804
811
what = msg ,
805
812
).save_and_notify (prevcommitter = prevcommitter )
806
813
0 commit comments