File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ from collections .abc import Sequence
2+
13import sqlalchemy
24from sqlalchemy .ext .asyncio import AsyncSession
35
46from nominees .tables import NomineeInfo
57
68
9+ async def get_all_nominees (
10+ db_session : AsyncSession ,
11+ ) -> Sequence [NomineeInfo ]:
12+ nominees = (await db_session .scalars (
13+ sqlalchemy
14+ .select (NomineeInfo )
15+ )).all ()
16+ return nominees
17+
718async def get_nominee_info (
819 db_session : AsyncSession ,
920 computing_id : str ,
Original file line number Diff line number Diff line change 1717)
1818
1919
20+ @router .get (
21+ "" ,
22+ description = "Get all nominees" ,
23+ response_model = list [NomineeInfoModel ],
24+ responses = {403 : {"description" : "need to be an admin" , "model" : DetailModel }},
25+ operation_id = "create_nominee" ,
26+ )
27+ async def get_all_nominees (
28+ request : Request ,
29+ db_session : database .DBSession ,
30+ ):
31+ # Putting this behind a wall since there is private information here
32+ await admin_or_raise (request , db_session )
33+ nominees_list = await nominees .crud .get_all_nominees (db_session )
34+
35+ return JSONResponse ([item .serialize () for item in nominees_list ])
36+
37+
2038@router .post (
2139 "" ,
2240 description = "Nominee info is always publically tied to election, so be careful!" ,
You can’t perform that action at this time.
0 commit comments