-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
73 lines (57 loc) · 2.14 KB
/
app.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from project.petclinic_model.specialty import Specialty
from project.petclinic_model.vet import Vet
from project.petclinic_model.pettype import PetType
from project.petclinic_model.visit import Visit
from project.petclinic_model.pet import Pet
from project.petclinic_model.owner import Owner
from project.petclinic_views import db, app
from project.petclinic_views import admin_service, user_service
def create_app():
# run_web()
with app.app_context():
db.create_all()
Owner.prepare_search()
Pet.prepare_search()
Visit.prepare_search()
PetType.prepare_search()
Vet.prepare_search()
Specialty.prepare_search()
user_service.prepare_default_user_login()
return app
@app.cli.command("db-create")
def admin_database_dump():
"""[Admin] database create"""
with app.app_context():
db.create_all()
user_service.prepare_default_user_login()
@app.cli.command("db-dump")
def admin_database_dump():
"""[Admin] database dump"""
with app.app_context():
admin_service.database_dump()
@app.cli.command("db-dump-reimport")
def admin_database_dump_reimport():
"""[Admin] database dump reimport"""
with app.app_context():
admin_service.database_dump_reimport()
@app.cli.command("db-drop-and-create")
def admin_database_drop_and_create():
"""[Admin] database drop and create"""
with app.app_context():
admin_service.database_drop_and_create()
@app.cli.command("db-table-count")
def admin_database_table_row_count():
"""[Admin] database table row count"""
with app.app_context():
admin_service.database_table_row_count()
# ---------------------------------------------------------------------------------
# MAIN
# ---------------------------------------------------------------------------------
if __name__ == "__main__":
app.logger.info("----------------------------------------------------")
app.logger.info(" MAIN ")
create_app()
with app.app_context():
db.create_all()
app.logger.info("----------------------------------------------------")
# run_web()