mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-12-05 01:04:21 +00:00
29 lines
694 B
Python
29 lines
694 B
Python
|
from typing import *
|
||
|
from royalnet.utils import *
|
||
|
from royalnet.constellation.api import *
|
||
|
from ..tables import Poll
|
||
|
import uuid
|
||
|
|
||
|
|
||
|
class ApiPollsList(ApiStar):
|
||
|
path = "/api/polls/list/v1"
|
||
|
|
||
|
summary = "Get a list of all polls."
|
||
|
|
||
|
requires_auth = True
|
||
|
|
||
|
tags = ["polls"]
|
||
|
|
||
|
async def api(self, data: ApiData) -> JSON:
|
||
|
PollT = self.alchemy.get(Poll)
|
||
|
|
||
|
polls: List[Poll] = await asyncify(data.session.query(PollT).all)
|
||
|
|
||
|
return list(map(lambda p: {
|
||
|
"id": p.id,
|
||
|
"question": p.question,
|
||
|
"creator": p.creator.json(),
|
||
|
"expires": p.expires.isoformat(),
|
||
|
"created": p.created.isoformat(),
|
||
|
}, polls))
|