File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-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 1616 tags = ["nominee" ],
1717)
1818
19+ @router .get (
20+ "" ,
21+ description = "Get all nominees" ,
22+ response_model = list [NomineeInfoModel ],
23+ responses = {
24+ 403 : { "description" : "need to be an admin" , "model" : DetailModel }
25+ },
26+ operation_id = "create_nominee"
27+ )
28+ async def get_all_nominees (
29+ request : Request ,
30+ db_session : database .DBSession ,
31+ ):
32+ # Putting this behind a wall since there is private information here
33+ await admin_or_raise (request , db_session )
34+ nominees_list = await nominees .crud .get_all_nominees (db_session )
35+
36+ return JSONResponse ([
37+ item .serialize () for item in nominees_list
38+ ])
39+
1940@router .post (
2041 "" ,
2142 description = "Nominee info is always publically tied to election, so be careful!" ,
You can’t perform that action at this time.
0 commit comments