Skip to content

Commit

Permalink
Future proof use of negative agreements in policies
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Dec 23, 2024
1 parent 2d16d55 commit 6331692
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/votes/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
PermissionGroupSlug,
PolicyDirection,
PolicyStatus,
StrVotePosition,
VotePosition,
)
from ..forms import (
Expand Down Expand Up @@ -679,18 +680,33 @@ def is_aligned(vote: Vote, link: PolicyDivisionLink) -> str:
if link.decision not in agreements:
continue
agreement = link.decision
if not link.decision.negative:
status = StrVotePosition.AYE
else:
status = StrVotePosition.NO

if (
status == StrVotePosition.AYE
and link.alignment == PolicyDirection.AGREE
):
alignment = "aligned"
elif (
status == StrVotePosition.NO
and link.alignment == PolicyDirection.AGAINST
):
alignment = "aligned"
else:
alignment = "not aligned"

agreement_items.append(
{
"motion": UrlColumn(
url=agreement.url(), text=agreement.decision_name
),
"date": agreement.date,
"collective_status": status,
"policy_direction": link.alignment,
# by definition it's aligned unless the policy wasn't the *oppinion* of the agreement
# generally don't want to make this happen in practice, but is possible
"policy_aligned": "aligned"
if link.alignment == PolicyDirection.AGREE
else "not aligned",
"policy_aligned": alignment,
"policy_strength": f"{link.strength.lower()}_agreements",
}
)
Expand Down

0 comments on commit 6331692

Please sign in to comment.