Skip to content

Commit 718ce25

Browse files
committed
fix: typing for officer positions
1 parent a6b60c1 commit 718ce25

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

src/elections/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def _get_user_permissions(
5151

5252
return has_permission, session_id, computing_id
5353

54-
def _default_election_positions(election_type: ElectionTypeEnum) -> list[str]:
54+
def _default_election_positions(election_type: ElectionTypeEnum) -> list[OfficerPositionEnum]:
5555
if election_type == ElectionTypeEnum.GENERAL:
5656
available_positions = GENERAL_ELECTION_POSITIONS
5757
elif election_type == ElectionTypeEnum.BY_ELECTION:
@@ -67,7 +67,7 @@ def _raise_if_bad_election_data(
6767
datetime_start_nominations: datetime,
6868
datetime_start_voting: datetime,
6969
datetime_end_voting: datetime,
70-
available_positions: list[str]
70+
available_positions: list[OfficerPositionEnum]
7171
):
7272
if election_type not in ElectionTypeEnum:
7373
raise HTTPException(

src/officers/constants.py

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from officers.types import OfficerPositionEnum
2+
3+
14
class OfficerPosition:
25
PRESIDENT = "president"
36
VICE_PRESIDENT = "vice-president"
@@ -23,7 +26,7 @@ class OfficerPosition:
2326
SOCIAL_MEDIA_MANAGER = "social media manager"
2427

2528
@staticmethod
26-
def position_list() -> list[str]:
29+
def position_list() -> list[OfficerPositionEnum]:
2730
return _OFFICER_POSITION_LIST
2831

2932
@staticmethod
@@ -152,45 +155,45 @@ def expected_positions() -> list[str]:
152155
}
153156

154157
_OFFICER_POSITION_LIST = [
155-
OfficerPosition.PRESIDENT,
156-
OfficerPosition.VICE_PRESIDENT,
157-
OfficerPosition.TREASURER,
158-
159-
OfficerPosition.DIRECTOR_OF_RESOURCES,
160-
OfficerPosition.DIRECTOR_OF_EVENTS,
161-
OfficerPosition.DIRECTOR_OF_EDUCATIONAL_EVENTS,
162-
OfficerPosition.ASSISTANT_DIRECTOR_OF_EVENTS,
163-
OfficerPosition.DIRECTOR_OF_COMMUNICATIONS,
164-
#OfficerPosition.DIRECTOR_OF_OUTREACH,
165-
OfficerPosition.DIRECTOR_OF_MULTIMEDIA,
166-
OfficerPosition.DIRECTOR_OF_ARCHIVES,
167-
OfficerPosition.EXECUTIVE_AT_LARGE,
168-
OfficerPosition.FIRST_YEAR_REPRESENTATIVE,
169-
170-
OfficerPosition.ELECTIONS_OFFICER,
171-
OfficerPosition.SFSS_COUNCIL_REPRESENTATIVE,
172-
OfficerPosition.FROSH_WEEK_CHAIR,
173-
174-
OfficerPosition.SYSTEM_ADMINISTRATOR,
175-
OfficerPosition.WEBMASTER,
176-
OfficerPosition.SOCIAL_MEDIA_MANAGER,
158+
OfficerPositionEnum.PRESIDENT,
159+
OfficerPositionEnum.VICE_PRESIDENT,
160+
OfficerPositionEnum.TREASURER,
161+
162+
OfficerPositionEnum.DIRECTOR_OF_RESOURCES,
163+
OfficerPositionEnum.DIRECTOR_OF_EVENTS,
164+
OfficerPositionEnum.DIRECTOR_OF_EDUCATIONAL_EVENTS,
165+
OfficerPositionEnum.ASSISTANT_DIRECTOR_OF_EVENTS,
166+
OfficerPositionEnum.DIRECTOR_OF_COMMUNICATIONS,
167+
#OfficerPositionEnum.DIRECTOR_OF_OUTREACH,
168+
OfficerPositionEnum.DIRECTOR_OF_MULTIMEDIA,
169+
OfficerPositionEnum.DIRECTOR_OF_ARCHIVES,
170+
OfficerPositionEnum.EXECUTIVE_AT_LARGE,
171+
OfficerPositionEnum.FIRST_YEAR_REPRESENTATIVE,
172+
173+
OfficerPositionEnum.ELECTIONS_OFFICER,
174+
OfficerPositionEnum.SFSS_COUNCIL_REPRESENTATIVE,
175+
OfficerPositionEnum.FROSH_WEEK_CHAIR,
176+
177+
OfficerPositionEnum.SYSTEM_ADMINISTRATOR,
178+
OfficerPositionEnum.WEBMASTER,
179+
OfficerPositionEnum.SOCIAL_MEDIA_MANAGER,
177180
]
178181

179182
GENERAL_ELECTION_POSITIONS = [
180-
OfficerPosition.PRESIDENT,
181-
OfficerPosition.VICE_PRESIDENT,
182-
OfficerPosition.TREASURER,
183-
184-
OfficerPosition.DIRECTOR_OF_RESOURCES,
185-
OfficerPosition.DIRECTOR_OF_EVENTS,
186-
OfficerPosition.DIRECTOR_OF_EDUCATIONAL_EVENTS,
187-
OfficerPosition.ASSISTANT_DIRECTOR_OF_EVENTS,
188-
OfficerPosition.DIRECTOR_OF_COMMUNICATIONS,
189-
#OfficerPosition.DIRECTOR_OF_OUTREACH,
190-
OfficerPosition.DIRECTOR_OF_MULTIMEDIA,
191-
OfficerPosition.DIRECTOR_OF_ARCHIVES,
183+
OfficerPositionEnum.PRESIDENT,
184+
OfficerPositionEnum.VICE_PRESIDENT,
185+
OfficerPositionEnum.TREASURER,
186+
187+
OfficerPositionEnum.DIRECTOR_OF_RESOURCES,
188+
OfficerPositionEnum.DIRECTOR_OF_EVENTS,
189+
OfficerPositionEnum.DIRECTOR_OF_EDUCATIONAL_EVENTS,
190+
OfficerPositionEnum.ASSISTANT_DIRECTOR_OF_EVENTS,
191+
OfficerPositionEnum.DIRECTOR_OF_COMMUNICATIONS,
192+
#OfficerPositionEnum.DIRECTOR_OF_OUTREACH,
193+
OfficerPositionEnum.DIRECTOR_OF_MULTIMEDIA,
194+
OfficerPositionEnum.DIRECTOR_OF_ARCHIVES,
192195
]
193196

194197
COUNCIL_REP_ELECTION_POSITIONS = [
195-
OfficerPosition.SFSS_COUNCIL_REPRESENTATIVE,
198+
OfficerPositionEnum.SFSS_COUNCIL_REPRESENTATIVE,
196199
]

tests/integration/test_elections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# info crud
1717
get_nominee_info,
1818
)
19-
from src.elections.urls import _slugify
2019
from src.main import app
2120

2221

0 commit comments

Comments
 (0)