Blame view

app/models.py 2.64 KB
76ef4fbe   hitier   Click, Sqlalchemy...
1
from flask_sqlalchemy import SQLAlchemy
454728d5   hitier   Use sqlalchemy re...
2
from sqlalchemy.orm import relationship
76ef4fbe   hitier   Click, Sqlalchemy...
3
4
5
6

db = SQLAlchemy()


d6b9daca   hitier   Feed categories a...
7
8
9
class Category(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32))
454728d5   hitier   Use sqlalchemy re...
10
    labels = relationship("CategoryLabel", back_populates='category')
d6b9daca   hitier   Feed categories a...
11
12
13
14
15
16


class CategoryLabel(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32))
    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
454728d5   hitier   Use sqlalchemy re...
17
    category = relationship("Category", back_populates='labels')
d6b9daca   hitier   Feed categories a...
18
19


ad3a824d   hitier   Add more agent fi...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class AgentBap(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(16))


class AgentGrade(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(16))


class AgentStatus(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(16))


class Company(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(16))


2784d9cc   hitier   Add models for ch...
40
41
42
43
class Agent(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    firstname = db.Column(db.String(100))
    secondname = db.Column(db.String(100))
ad3a824d   hitier   Add more agent fi...
44
45
46
47
48
49
    company_id = db.Column(db.Integer, db.ForeignKey('company.id'))
    grade_id = db.Column(db.Integer, db.ForeignKey('agent_grade.id'))
    status_id = db.Column(db.Integer, db.ForeignKey('agent_status.id'))
    bap_id = db.Column(db.Integer, db.ForeignKey('agent_bap.id'))
    virtual = db.Column(db.Integer)  # integer boolean
    permanent = db.Column(db.Integer)  # integer boolean
2784d9cc   hitier   Add models for ch...
50
51
52
53
54
55
56
57
58
59


class Project(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)


class Service(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)
1002c994   hitier   Also feed ids fro...
60
    abbr = db.Column(db.String(50), unique=True)
2784d9cc   hitier   Add models for ch...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83


class Function(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)


class Capacity(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)


class Period(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100), unique=True)
    num_months = db.Column(db.Integer)


class Charge(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    agent_id = db.Column(db.Integer, db.ForeignKey('agent.id'))
    project_id = db.Column(db.Integer, db.ForeignKey('project.id'))
    service_id = db.Column(db.Integer, db.ForeignKey('service.id'))
582b4b3a   hitier   Add capacity comp...
84
    capacity_id = db.Column(db.Integer, db.ForeignKey('capacity.id'))
2784d9cc   hitier   Add models for ch...
85
86
    period_id = db.Column(db.Integer, db.ForeignKey('period.id'))
    charge_rate = db.Column(db.Integer)