@@ -189,7 +189,9 @@ def current_patch_on_commitfest(self):
189189 # The unique partial index poc_enforce_maxoneoutcome_idx stores the PoC
190190 # No caching here (inside the instance) since the caller should just need
191191 # 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+ )
193195
194196 # Some accessors
195197 @property
@@ -560,9 +562,10 @@ class CfbotTask(models.Model):
560562# the workflow this application is built for. These elements exist
561563# independent of what the user is presently seeing on their page.
562564class Workflow (models .Model ):
563-
564565 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 ()
566569
567570 # At most a single Open CommitFest is allowed and this function returns it.
568571 def open_cf ():
@@ -603,9 +606,8 @@ def isCommitter(user, patch):
603606 is_committer = is_this_committer = False
604607 return is_committer , is_this_committer , all_committers
605608
606-
607609 def getCommitfest (cfid ):
608- if ( cfid is None or cfid == "" ) :
610+ if cfid is None or cfid == "" :
609611 return None
610612 try :
611613 int_cfid = int (cfid )
@@ -624,7 +626,7 @@ def createNewPOC(patch, commitfest, initial_status, by_user):
624626 poc , created = PatchOnCommitFest .objects .update_or_create (
625627 patch = patch ,
626628 commitfest = commitfest ,
627- defaults = dict (
629+ defaults = dict (
628630 enterdate = datetime .now (),
629631 status = initial_status ,
630632 leavedate = None ,
@@ -635,10 +637,9 @@ def createNewPOC(patch, commitfest, initial_status, by_user):
635637 poc .save ()
636638
637639 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 ),
642643 ).save_and_notify ()
643644
644645 return poc
@@ -659,16 +660,9 @@ def transitionPatch(poc, target_cf, by_user):
659660 # not allowed to change non-current commitfest status
660661 # and once the new POC is created it becomes current.
661662
662- Workflow .updatePOCStatus (
663- poc ,
664- PatchOnCommitFest .STATUS_NEXT ,
665- by_user )
663+ Workflow .updatePOCStatus (poc , PatchOnCommitFest .STATUS_NEXT , by_user )
666664
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 )
672666
673667 return new_poc
674668
@@ -702,7 +696,7 @@ def userCanTransitionPatch(poc, target_cf, user):
702696 # Prevent users from moving closed patches, or moving open ones to
703697 # non-open, non-future commitfests. The else clause should be a
704698 # 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 ):
706700 pass
707701 else :
708702 # Default deny policy basis
@@ -723,7 +717,10 @@ def userCanChangePOCStatus(poc, new_status, user):
723717 # We want commits to happen from, usually, In Progress commitfests,
724718 # or Open ones for exempt patches. We accept Future ones too just because
725719 # 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+ ):
727724 raise Exception ("Cannot change status to committed in a parked commitfest." )
728725
729726 # We trust privileged users to make informed choices
@@ -743,7 +740,10 @@ def userCanChangePOCStatus(poc, new_status, user):
743740 if new_status == PatchOnCommitFest .STATUS_RETURNED and not is_committer :
744741 raise Exception ("Only a committer can set status to returned." )
745742
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+ ):
747747 raise Exception ("Only the author can set status to withdrawn." )
748748
749749 # Prevent users from modifying closed patches
@@ -753,13 +753,12 @@ def userCanChangePOCStatus(poc, new_status, user):
753753 else :
754754 raise Exception ("Cannot change status of closed patch." )
755755
756-
757756 # Update the status of a PoC
758757 # Returns True if the status was changed, False for a same-status no-op.
759758 # Creates history and notifies as a side-effect.
760759 def updatePOCStatus (poc , new_status , by_user ):
761760 # 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 :
763762 return False
764763
765764 Workflow .userCanChangePOCStatus (poc , new_status , by_user )
@@ -770,11 +769,12 @@ def updatePOCStatus(poc, new_status, by_user):
770769 poc .patch .save ()
771770 poc .save ()
772771 PatchHistory (
773- patch = poc .patch , by = by_user ,
772+ patch = poc .patch ,
773+ by = by_user ,
774774 what = "{} in {}" .format (
775775 poc .statusstring ,
776776 poc .commitfest .name ,
777- ),
777+ ),
778778 ).save_and_notify ()
779779
780780 return True
@@ -783,7 +783,7 @@ def updatePOCStatus(poc, new_status, by_user):
783783 # Returns True if the committer was changed, False for a same-committer no-op.
784784 # Creates history and notifies as a side-effect.
785785 def setCommitter (poc , committer , by_user ):
786- if ( poc .patch .committer == committer ) :
786+ if poc .patch .committer == committer :
787787 return False
788788
789789 prevcommitter = poc .patch .committer
@@ -793,14 +793,21 @@ def setCommitter(poc, committer, by_user):
793793 poc .save ()
794794
795795 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+ )
797799 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+ )
799803 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+ )
801807
802808 PatchHistory (
803- patch = poc .patch , by = by_user ,
809+ patch = poc .patch ,
810+ by = by_user ,
804811 what = msg ,
805812 ).save_and_notify (prevcommitter = prevcommitter )
806813
0 commit comments