Create initial election cycle class.

This commit is contained in:
2023-05-13 10:55:36 -04:00
parent 9d2382bf1d
commit f62f88113d
+69
View File
@@ -0,0 +1,69 @@
"""
Contains the election cycle class
"""
from datetime import datetime, timedelta
class ElectionCycle:
"""
This class represents all the dates required for an election cycle along with all the functions needed to operate
the cycle.
"""
def __init__(self, election_start: datetime, term_start: datetime, term_end: datetime) -> None:
"""
Generates all dates relevant to the election cycle from input election start, term start and end dates.
Args:
election_start (datetime): Date the election cycle starts.
term_start (datetime): Date the term being elected starts.
term_end (datetime): Date the term being elected ends.
"""
self.election_start: datetime = election_start
self.term_start: datetime = term_start
self.term_end: datetime = term_end # might not be needed
self.voting_start: datetime = self.election_start + timedelta(days=7)
self.voting_end: datetime = self.voting_start + timedelta(days=7)
self.highcouncil_election: datetime = self.voting_end + timedelta(days=1)
def check_date(self) -> None:
"""
Function checks current date to see if something needs to be run.
"""
today = datetime.today()
# check all dates if action is needed
match today.date():
case self.election_start.date():
self.election_start_action()
case self.voting_start.date():
self.voting_end_action()
case self.voting_end.date():
self.voting_end_action()
case self.highcouncil_election.date():
self.highcouncil_election_action()
def election_start_action(self) -> None:
"""
Performs required actions for when the election cycle starts.
"""
print("election cycle has started")
def voting_start_action(self) -> None:
"""
Performs required actions for when voting for candidates starts.
"""
print("Voting has started")
def voting_end_action(self) -> None:
"""
Performs required actions for when voting time has ended.
"""
print("voting has ended")
def highcouncil_election_action(self) -> None:
"""
Performs required actions for when the highcouncil is elected.
"""
print("Highcouncil election has started.")