1515# set default button sytle and size, will be overwritten by macro parameters
1616app .config ['BOOTSTRAP_BTN_STYLE' ] = 'primary'
1717app .config ['BOOTSTRAP_BTN_SIZE' ] = 'sm'
18- # app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = 'lumen' # uncomment this line to test bootswatch theme
1918
2019# set default icon title of table actions
2120app .config ['BOOTSTRAP_TABLE_VIEW_TITLE' ] = 'Read'
@@ -89,6 +88,40 @@ class ContactForm(FlaskForm):
8988 im_accounts = FieldList (FormField (IMForm ), min_entries = 2 )
9089
9190
91+ class BootswatchForm (FlaskForm ):
92+ """Form to test Bootswatch."""
93+ #DO NOT EDIT! Use list-bootswatch.py te generate the Radiofield below.
94+ render = RadioField (default = 'default' ,
95+ choices = [('default' , 'none' ),
96+ ('cerulean' , 'Cerulean 5.1.3' ),
97+ ('cosmo' , 'Cosmo 5.1.3' ),
98+ ('cyborg' , 'Cyborg 5.1.3' ),
99+ ('darkly' , 'Darkly 5.1.3' ),
100+ ('flatly' , 'Flatly 5.1.3' ),
101+ ('journal' , 'Journal 5.1.3' ),
102+ ('litera' , 'Litera 5.1.3' ),
103+ ('lumen' , 'Lumen 5.1.3' ),
104+ ('lux' , 'Lux 5.1.3' ),
105+ ('materia' , 'Materia 5.1.3' ),
106+ ('minty' , 'Minty 5.1.3' ),
107+ ('morph' , 'Morph 5.1.3' ),
108+ ('pulse' , 'Pulse 5.1.3' ),
109+ ('quartz' , 'Quartz 5.1.3' ),
110+ ('sandstone' , 'Sandstone 5.1.3' ),
111+ ('simplex' , 'Simplex 5.1.3' ),
112+ ('sketchy' , 'Sketchy 5.1.3' ),
113+ ('slate' , 'Slate 5.1.3' ),
114+ ('solar' , 'Solar 5.1.3' ),
115+ ('spacelab' , 'Spacelab 5.1.3' ),
116+ ('superhero' , 'Superhero 5.1.3' ),
117+ ('united' , 'United 5.1.3' ),
118+ ('vapor' , 'Vapor 5.1.3' ),
119+ ('yeti' , 'Yeti 5.1.3' ),
120+ ('zephyr' , 'Zephyr 5.1.3' ),
121+ ])
122+ submit = SubmitField ()
123+
124+
92125class Message (db .Model ):
93126 id = db .Column (db .Integer , primary_key = True )
94127 text = db .Column (db .Text , nullable = False )
@@ -155,10 +188,26 @@ def test_nav():
155188 return render_template ('nav.html' )
156189
157190
191+ @app .route ('/bootswatch' , methods = ['GET' , 'POST' ])
192+ def test_bootswatch ():
193+ form = BootswatchForm ()
194+ if form .validate_on_submit ():
195+ print ('FFFFF' , app .config ['BOOTSTRAP_BOOTSWATCH_THEME' ])
196+ if form .render .data == 'default' :
197+ app .config ['BOOTSTRAP_BOOTSWATCH_THEME' ] = None
198+ else :
199+ app .config ['BOOTSTRAP_BOOTSWATCH_THEME' ] = form .render .data
200+ flash (f'Render style has been set to { form .render .data } .' )
201+ else :
202+ if app .config ['BOOTSTRAP_BOOTSWATCH_THEME' ] != None :
203+ form .render .data = app .config ['BOOTSTRAP_BOOTSWATCH_THEME' ]
204+ return render_template ('bootswatch.html' , form = form )
205+
206+
158207@app .route ('/pagination' , methods = ['GET' , 'POST' ])
159208def test_pagination ():
160209 page = request .args .get ('page' , 1 , type = int )
161- pagination = Message .query .paginate (page , per_page = 10 )
210+ pagination = Message .query .paginate (page = page , per_page = 10 )
162211 messages = pagination .items
163212 return render_template ('pagination.html' , pagination = pagination , messages = messages )
164213
@@ -181,7 +230,7 @@ def test_flash():
181230@app .route ('/table' )
182231def test_table ():
183232 page = request .args .get ('page' , 1 , type = int )
184- pagination = Message .query .paginate (page , per_page = 10 )
233+ pagination = Message .query .paginate (page = page , per_page = 10 )
185234 messages = pagination .items
186235 titles = [('id' , '#' ), ('text' , 'Message' ), ('author' , 'Author' ), ('category' , 'Category' ), ('draft' , 'Draft' ), ('create_time' , 'Create Time' )]
187236 data = []
0 commit comments