-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
27 lines (22 loc) · 828 Bytes
/
models.py
File metadata and controls
27 lines (22 loc) · 828 Bytes
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
from config import db
from category import Category
from datetime import datetime, UTC
class Users(db.Model):
username = db.Column(db.String, primary_key=True)
password = db.Column(db.LargeBinary(64))
class Tasks(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
username = db.Column(db.String, db.ForeignKey("users.username"))
description = db.Column(db.String)
category = db.Column(db.Enum(Category))
amount = db.Column(db.Float)
date = db.Column(db.Date, default=datetime.now(UTC).date)
def serialize(self):
return {
"id": self.id,
"username": self.username,
"description": self.description,
"category": self.category.name,
"amount": self.amount,
"date": self.date
}