-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
28 lines (22 loc) · 867 Bytes
/
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
from flask_sqlalchemy import SQLAlchemy
from enum import Enum
# Create models
db = SQLAlchemy()
class StatusEnum(Enum):
UNASSIGNED = 'Unassigned'
ASSIGNED = 'Assigned'
PENDING = 'Pending'
COMPLETED = 'Completed'
IN_PROGRESS = 'In Progress'
class Employee(db.Model):
__tablename__ = 'employees'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50), nullable=False)
tasks = db.relationship('Task', backref='employee', lazy=True)
class Task(db.Model):
__tablename__ = 'tasks'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100), nullable=False)
description = db.Column(db.String(200))
status = db.Column(db.Enum(StatusEnum), nullable=False, default=StatusEnum.UNASSIGNED)
employee_id = db.Column(db.Integer, db.ForeignKey('employees.id'), nullable=False)