Add active parameter to elections. Only return an election for use if the election is active.

This commit is contained in:
2024-09-07 15:46:30 -04:00
parent 70676a98dd
commit 3c31d0ad33
5 changed files with 21 additions and 14 deletions
+5 -3
View File
@@ -64,7 +64,7 @@ def get_election_name() -> str:
Returns:
str: the name of the election cycle
"""
cycle = get_current_election_cycle()
cycle = get_active_election_cycle()
current_cycle = settings.election_cycles[cycle]
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
@@ -82,7 +82,7 @@ def get_quarter_name() -> str:
return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
def get_current_election_cycle() -> int:
def get_active_election_cycle() -> int:
"""
Returns index for active election. An election is considered active between the election start and the term start.
@@ -104,7 +104,9 @@ def get_current_election_cycle() -> int:
def get_quarter_cycle() -> int:
"""
Returns the index for the current cycle/quarter. Defined as between term start and end. Shouldn't return none.
Returns the index for the current cycle/quarter. Defined as between term start and end.
Can return None if entire year isn't covered by cycles.
Returns:
int: cycle index for current cycle.