-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
66 lines (51 loc) · 1.21 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from typing import List, Optional
from pydantic import BaseModel
class DateTime(BaseModel):
year: int
month: int
day: int
hours: int
minutes: int
class UserBase(BaseModel):
name: str
email: str
password: str
organisations: List[str]
class UserCreate(UserBase):
pass
class User(UserBase):
key: str
class Result(BaseModel):
choice: int
votes: int
who_voted: List[str] # who voted (key) #SAM - changed this from a string to a list
class Choice(BaseModel):
description: str
id: int
class PollBase(BaseModel):
name: str
description: str
anonymous: bool
start_time: DateTime # epoch time
end_time: DateTime # epoch time
organisation_key: str
class PollCreate(PollBase):
choices: List[str]
pass
class Poll(PollBase):
choices: List[Choice] =[]
results: List[Result] = []
total_votes: int = 0
key:str = ""
organisation_name: str = ""
class PollView(PollBase):
choices: List[Choice] =[]
organisation_name: str = ""
class OrganisationBase(BaseModel):
name: str
description: str
admins: List[str]
class OrganisationCreate(OrganisationBase):
pass
class Organisation(OrganisationBase):
key:str