-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
32 lines (25 loc) · 934 Bytes
/
run.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
29
30
31
32
from os import getenv
from app import create_app
from app.models import Area, Comment, Concept, Country, Document, DocumentType, Index, Region, \
Role, State, Travel, User, Workflow, db
app = create_app(getenv('FLASK_CONFIG') or 'default')
@app.shell_context_processor
def make_shell_context():
return dict(app=app, Area=Area, Comment=Comment, Concept=Concept, Country=Country, \
Document=Document, DocumentType=DocumentType, Index=Index, Region=Region, \
Role=Role, State=State, Travel=Travel, User=User, Workflow=Workflow, db=db)
@app.cli.command()
def init():
insert(Area)
insert(Concept)
insert(Country)
insert(DocumentType)
insert(Role)
insert(User)
insert(State)
insert(Travel)
insert(Document)
def insert(model):
print(f'Inserting table {model.__tablename__} ...')
model.insert()
print(f'Table {model.__tablename__} inserted - OK')