-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
45 lines (33 loc) · 1.23 KB
/
models.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
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime
from sqlalchemy.orm import descriptor_props, relationship
from .database import Base
# can you see this? yes
# nice
class User(Base):
__tablename__ = "users"
#id: str
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
email = Column(String, unique=True)
pw = Column(String)
organisations = Column(String)
class Poll(Base):
__tablename__ = "polls"
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
description = Column(String)
anonymous = Column(Boolean)
total_votes = Column(Integer)
start_time = Column(DateTime)
end_time = Column(DateTime)
organisation_id = Column(Integer, ForeignKey("organisations.id"))
results = Column(String) # [{choice: id, votes: int}]
choices = Column(String) # [{description: int, id: int}]
organisation = relationship("Organisation", back_populates="poll")
class Organisation(Base):
__tablename__ = "organisations"
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
description = Column(String)
admins = Column(String)
poll = relationship("Poll", back_populates="organisation")