forked from exam-of-three-people/exam_ol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
44 lines (33 loc) · 1.22 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
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_admin.form import BaseForm
from flask_bootstrap import Bootstrap
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from wtforms import StringField
from wtforms.validators import DataRequired
from models import Student, Teacher, College, Major, Subject, Page, Test, Class, db
from views import app
bootstrap = Bootstrap()
bootstrap.init_app(app)
app.config['BOOTSTRAP_SERVE_LOCAL'] = True
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
admin = Admin()
admin.init_app(app)
class IdBrandForm(BaseForm):
id = StringField(validators=[DataRequired()])
class IdBrandModelView(ModelView):
column_display_pk = True
form_base_class = IdBrandForm
admin.add_view(IdBrandModelView(Student, db.session))
admin.add_view(IdBrandModelView(Teacher, db.session))
admin.add_view(ModelView(College, db.session))
admin.add_view(ModelView(Major, db.session))
admin.add_view(ModelView(Subject, db.session))
admin.add_view(ModelView(Page, db.session))
admin.add_view(ModelView(Test, db.session))
admin.add_view(ModelView(Class, db.session))
if __name__ == '__main__':
manager.run()