-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
42 lines (35 loc) · 1.57 KB
/
models.py
File metadata and controls
42 lines (35 loc) · 1.57 KB
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
from database import db
from datetime import datetime
class Audited:
created_at = db.Column("created_at",
db.DateTime, nullable=False, default=datetime.now())
modified_at = db.Column("modified_at",
db.DateTime, nullable=False, default=datetime.now())
class List(db.Model, Audited):
''' This class represents a list '''
__tablename__ = "lists"
id = db.Column("id", db.Integer, primary_key=True)
name = db.Column("name", db.String, nullable=False)
recurring_deadline = db.Column("recurring_deadline",
db.Time, nullable=False)
tasks = db.relationship("Task", backref="task_list")
list_properties = db.relationship("ListProperty", backref="task_list")
class Task(db.Model, Audited):
''' This class represents a task '''
__tablename__ = "tasks"
id = db.Column("id", db.Integer, primary_key=True)
name = db.Column("name", db.String, nullable=False)
status = db.Column("status", db.String, nullable=False)
description = db.Column("description", db.String)
list_id = db.Column("list_id", db.ForeignKey(List.id),
nullable=False)
# can be used for further extending the functionality of the list
# in the future.
class ListProperty(db.Model, Audited):
''' This class represents list properties'''
__tablename__ = "list_properties"
id = db.Column("id", db.Integer, primary_key=True)
name = db.Column("name", db.String, nullable=False)
value = db.Column("value", db.String, nullable=False)
list_id = db.Column("list_id", db.ForeignKey(List.id),
nullable=False)