Commit 2784d9ccaba066e1961fbbc48d3a0fa9def6b962
1 parent
25040dc3
Exists in
master
and in
4 other branches
Add models for charges
Showing
3 changed files
with
125 additions
and
3 deletions
Show diff stats
app/models.py
... | ... | @@ -7,9 +7,50 @@ db = SQLAlchemy() |
7 | 7 | class User(UserMixin, db.Model): |
8 | 8 | id = db.Column(db.Integer, primary_key=True) # primary keys are required by SQLAlchemy |
9 | 9 | email = db.Column(db.String(100), unique=True) |
10 | - name = db.Column(db.String(1000)) | |
11 | - login = db.Column(db.String(1000), unique=True) | |
10 | + name = db.Column(db.String(100)) | |
11 | + login = db.Column(db.String(100), unique=True) | |
12 | 12 | password = db.Column(db.String(100)) |
13 | 13 | |
14 | 14 | def __repr__(self): |
15 | - return "i: {}, n: {}, e: {}, l: {}, p: {}".format(self.id, self.name, self.email, self.login, self.password) | |
15 | + return "i: {}, n: {}, e: {}, l: {}".format(self.id, self.name, self.email, self.login) | |
16 | + | |
17 | + | |
18 | +class Agent(db.Model): | |
19 | + id = db.Column(db.Integer, primary_key=True) | |
20 | + firstname = db.Column(db.String(100)) | |
21 | + secondname = db.Column(db.String(100)) | |
22 | + | |
23 | + | |
24 | +class Project(db.Model): | |
25 | + id = db.Column(db.Integer, primary_key=True) | |
26 | + name = db.Column(db.String(100), unique=True) | |
27 | + | |
28 | + | |
29 | +class Service(db.Model): | |
30 | + id = db.Column(db.Integer, primary_key=True) | |
31 | + name = db.Column(db.String(100), unique=True) | |
32 | + | |
33 | + | |
34 | +class Function(db.Model): | |
35 | + id = db.Column(db.Integer, primary_key=True) | |
36 | + name = db.Column(db.String(100), unique=True) | |
37 | + | |
38 | + | |
39 | +class Capacity(db.Model): | |
40 | + id = db.Column(db.Integer, primary_key=True) | |
41 | + name = db.Column(db.String(100), unique=True) | |
42 | + | |
43 | + | |
44 | +class Period(db.Model): | |
45 | + id = db.Column(db.Integer, primary_key=True) | |
46 | + name = db.Column(db.String(100), unique=True) | |
47 | + num_months = db.Column(db.Integer) | |
48 | + | |
49 | + | |
50 | +class Charge(db.Model): | |
51 | + id = db.Column(db.Integer, primary_key=True) | |
52 | + agent_id = db.Column(db.Integer, db.ForeignKey('agent.id')) | |
53 | + project_id = db.Column(db.Integer, db.ForeignKey('project.id')) | |
54 | + service_id = db.Column(db.Integer, db.ForeignKey('service.id')) | |
55 | + period_id = db.Column(db.Integer, db.ForeignKey('period.id')) | |
56 | + charge_rate = db.Column(db.Integer) | ... | ... |
... | ... | @@ -0,0 +1,54 @@ |
1 | +"""empty message | |
2 | + | |
3 | +Revision ID: 6f7e51f380eb | |
4 | +Revises: 20f2c14aa0b6 | |
5 | +Create Date: 2021-03-09 09:47:34.679802 | |
6 | + | |
7 | +""" | |
8 | +from alembic import op | |
9 | +import sqlalchemy as sa | |
10 | + | |
11 | + | |
12 | +# revision identifiers, used by Alembic. | |
13 | +revision = '6f7e51f380eb' | |
14 | +down_revision = '20f2c14aa0b6' | |
15 | +branch_labels = None | |
16 | +depends_on = None | |
17 | + | |
18 | + | |
19 | +def upgrade(): | |
20 | + # ### commands auto generated by Alembic - please adjust! ### | |
21 | + op.create_table('agent', | |
22 | + sa.Column('id', sa.Integer(), nullable=False), | |
23 | + sa.Column('name', sa.String(length=1000), nullable=True), | |
24 | + sa.PrimaryKeyConstraint('id'), | |
25 | + sa.UniqueConstraint('name') | |
26 | + ) | |
27 | + op.create_table('fonction', | |
28 | + sa.Column('id', sa.Integer(), nullable=False), | |
29 | + sa.Column('name', sa.String(length=1000), nullable=True), | |
30 | + sa.PrimaryKeyConstraint('id'), | |
31 | + sa.UniqueConstraint('name') | |
32 | + ) | |
33 | + op.create_table('project', | |
34 | + sa.Column('id', sa.Integer(), nullable=False), | |
35 | + sa.Column('name', sa.String(length=1000), nullable=True), | |
36 | + sa.PrimaryKeyConstraint('id'), | |
37 | + sa.UniqueConstraint('name') | |
38 | + ) | |
39 | + op.create_table('service', | |
40 | + sa.Column('id', sa.Integer(), nullable=False), | |
41 | + sa.Column('name', sa.String(length=1000), nullable=True), | |
42 | + sa.PrimaryKeyConstraint('id'), | |
43 | + sa.UniqueConstraint('name') | |
44 | + ) | |
45 | + # ### end Alembic commands ### | |
46 | + | |
47 | + | |
48 | +def downgrade(): | |
49 | + # ### commands auto generated by Alembic - please adjust! ### | |
50 | + op.drop_table('service') | |
51 | + op.drop_table('project') | |
52 | + op.drop_table('fonction') | |
53 | + op.drop_table('agent') | |
54 | + # ### end Alembic commands ### | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +POSTGRES = { | |
2 | + 'user': 'postgres', | |
3 | + 'pw': 'postgres', | |
4 | + 'db': 'climso', | |
5 | + 'host': '127.0.0.1', | |
6 | + 'port': '5434', | |
7 | +} | |
8 | +postgres_uri = 'postgresql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % POSTGRES | |
9 | + | |
10 | +SQLITE = { | |
11 | + 'file': '/home/richard/tmp/climso.db' | |
12 | +} | |
13 | +sqlite_uri = 'sqlite:///%(file)s' % SQLITE | |
14 | + | |
15 | +database_uri = sqlite_uri | |
16 | +database_uri = postgres_uri | |
17 | + | |
18 | +data_basedir = '/data/CLIMSO' | |
19 | + | |
20 | +MYSQL = { | |
21 | + 'user': 'mysql', | |
22 | + 'pw': 'mysql', | |
23 | + 'db': 'pdc_dev', | |
24 | + 'host': '127.0.0.1', | |
25 | + 'port': '3306', | |
26 | +} | |
27 | +mysql_uri = 'mysql+pymysql://%(user)s:%(pw)s@%(host)s:%(port)s/%(db)s' % MYSQL | ... | ... |