<s> from flask_appbuilder import ModelView <EOL> from flask_appbuilder . fieldwidgets import Select2Widget <EOL> from flask . ext . appbuilder . models . sqla . interface import SQLAInterface <EOL> from . models import Employee , Department , Function , EmployeeHistory , Benefit <EOL> from wtforms . ext . sqlalchemy . fields import QuerySelectField <EOL> from app import appbuilder , db <EOL> def department_query ( ) : <EOL> return db . session . query ( Department ) <EOL> class EmployeeHistoryView ( ModelView ) : <EOL> datamodel = SQLAInterface ( EmployeeHistory ) <EOL> list_columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class EmployeeView ( ModelView ) : <EOL> datamodel = SQLAInterface ( Employee ) <EOL> list_columns = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> edit_form_extra_fields = { '<STR_LIT>' : QuerySelectField ( '<STR_LIT>' , <EOL> query_factory = department_query , <EOL> widget = Select2Widget ( extra_classes = "<STR_LIT>" ) ) } <EOL> related_views = [ EmployeeHistoryView ] <EOL> show_template = '<STR_LIT>' <EOL> class FunctionView ( ModelView ) : <EOL> datamodel = SQLAInterface ( Function ) <EOL> related_views = [ EmployeeView ] <EOL> class DepartmentView ( ModelView ) : <EOL> datamodel = SQLAInterface ( Department ) <EOL> related_views = [ EmployeeView ] <EOL> class BenefitView ( ModelView ) : <EOL> datamodel = SQLAInterface ( Benefit ) <EOL> add_columns = [ '<STR_LIT:name>' ] <EOL> edit_columns = [ '<STR_LIT:name>' ] <EOL> show_columns = [ '<STR_LIT:name>' ] <EOL> list_columns = [ '<STR_LIT:name>' ] <EOL> db . create_all ( ) <EOL> appbuilder . add_view_no_menu ( EmployeeHistoryView , "<STR_LIT>" ) <EOL> appbuilder . add_view ( EmployeeView , "<STR_LIT>" , icon = "<STR_LIT>" , category = "<STR_LIT>" ) <EOL> appbuilder . add_separator ( "<STR_LIT>" ) <EOL> appbuilder . add_view ( DepartmentView , "<STR_LIT>" , icon = "<STR_LIT>" , category = "<STR_LIT>" ) <EOL> appbuilder . add_view ( FunctionView , "<STR_LIT>" , icon = "<STR_LIT>" , category = "<STR_LIT>" ) <EOL> appbuilder . add_view ( BenefitView , "<STR_LIT>" , icon = "<STR_LIT>" , category = "<STR_LIT>" ) </s>
