Skip to content

Commit e6dd8ac

Browse files
committed
Perform format and lint run.
1 parent a166d50 commit e6dd8ac

11 files changed

+589
-569
lines changed

pgcommitfest/commitfest/migrations/0011_add_status_related_constraints.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.db import migrations
22

3+
34
class Migration(migrations.Migration):
45
dependencies = [
56
("commitfest", "0010_add_failing_since_column"),
@@ -10,19 +11,16 @@ class Migration(migrations.Migration):
1011
ON commitfest_commitfest (status)
1112
WHERE status not in (4);
1213
"""),
13-
1414
migrations.RunSQL("""
1515
CREATE UNIQUE INDEX poc_enforce_maxoneoutcome_idx
1616
ON commitfest_patchoncommitfest (patch_id)
1717
WHERE status not in (5);
1818
"""),
19-
2019
migrations.RunSQL("""
2120
ALTER TABLE commitfest_patchoncommitfest
2221
ADD CONSTRAINT status_and_leavedate_correlation
2322
CHECK ((status IN (4,5,6,7,8)) = (leavedate IS NOT NULL));
2423
"""),
25-
2624
migrations.RunSQL("""
2725
COMMENT ON COLUMN commitfest_patchoncommitfest.leavedate IS
2826
$$A leave date is recorded in two situations, both of which
@@ -31,7 +29,6 @@ class Migration(migrations.Migration):
3129
to some other cf. For 4,6,7, and 8, this was the final cf.
3230
$$
3331
"""),
34-
3532
migrations.RunSQL("""
3633
COMMENT ON TABLE commitfest_patchoncommitfest IS
3734
$$This is a re-entrant table: patches may become associated

pgcommitfest/commitfest/migrations/0012_add_parked_cf_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.db import migrations, models
22

3+
34
class Migration(migrations.Migration):
45
dependencies = [
56
("commitfest", "0011_add_status_related_constraints"),

pgcommitfest/commitfest/models.py

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
562564
class 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

pgcommitfest/commitfest/templates/patch.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ <h3>History</h3>
7676
</table>
7777
</div>
7878
{%if user.is_authenticated %}
79-
{%include "patch_table_keyvalue.inc"%}
79+
{%include "patch_table_keyvalue.inc"%}
8080
{%endif%}
8181

8282
{%comment%}commit dialog{%endcomment%}

pgcommitfest/commitfest/templates/patch_administrative.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,28 @@
2828
<li role="presentation">
2929
<a
3030
href="transition/?fromcfid={{poc.commitfest.id}}&tocfid={{workflow.future.id}}">
31-
{{workflow.future.name}}</a>
31+
{{workflow.future.name}}</a>
3232
</li>
3333
{%endif%}
3434
{%if not cf.isopen and workflow.open %}
3535
<li role="presentation">
3636
<a
3737
href="transition/?fromcfid={{poc.commitfest.id}}&tocfid={{workflow.open.id}}">
38-
{{workflow.open.name}}</a>
38+
{{workflow.open.name}}</a>
3939
</li>
4040
{%endif%}
4141
{%if not cf.isinprogress and workflow.progress %}
4242
<li role="presentation">
4343
<a
4444
href="transition/?fromcfid={{poc.commitfest.id}}&tocfid={{workflow.progress.id}}">
45-
{{workflow.progress.name}}</a>
45+
{{workflow.progress.name}}</a>
4646
</li>
4747
{%endif%}
4848
{%if not cf.isparked and workflow.parked %}
4949
<li role="presentation">
5050
<a
5151
href="transition/?fromcfid={{poc.commitfest.id}}&tocfid={{workflow.parked.id}}">
52-
{{workflow.parked.name}}</a>
52+
{{workflow.parked.name}}</a>
5353
</li>
5454
{%endif%}
5555
</ul>

0 commit comments

Comments
 (0)