Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/bootstrap4/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from flask_wtf import FlaskForm, CSRFProtect
from wtforms.validators import DataRequired, Length, Regexp
from wtforms.fields import *
from flask_bootstrap import Bootstrap4, SwitchField
from flask_sqlalchemy import SQLAlchemy
from flask_bootstrap import Bootstrap4, SwitchField

app = Flask(__name__)
app.secret_key = 'dev'
Expand Down Expand Up @@ -34,6 +34,7 @@

class ExampleForm(FlaskForm):
"""An example form that contains all the supported bootstrap style form fields."""

date = DateField(description="We'll never share your email with anyone else.") # add help text with `description`
datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw`
datetime_local = DateTimeLocalField()
Expand All @@ -52,8 +53,8 @@ class ExampleForm(FlaskForm):
select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
bio = TextAreaField()
search = SearchField() # will autocapitalize on mobile
title = StringField() # will not autocapitalize on mobile
search = SearchField() # will autocapitalize on mobile
title = StringField() # will not autocapitalize on mobile
secret = PasswordField()
remember = BooleanField('Remember me')
submit = SubmitField()
Expand Down Expand Up @@ -96,7 +97,8 @@ class ContactForm(FlaskForm):

class BootswatchForm(FlaskForm):
"""Form to test Bootswatch."""
#DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.

# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
theme_name = RadioField(
default='default',
choices=[
Expand Down Expand Up @@ -208,7 +210,7 @@ def test_bootswatch():
app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data
flash(f'Render style has been set to {form.theme_name.data}.')
else:
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None:
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None:
form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME']
return render_template('bootswatch.html', form=form)

Expand Down
12 changes: 7 additions & 5 deletions examples/bootstrap5/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from flask_wtf import FlaskForm, CSRFProtect
from wtforms.validators import DataRequired, Length, Regexp
from wtforms.fields import *
from flask_bootstrap import Bootstrap5, SwitchField
from flask_sqlalchemy import SQLAlchemy
from flask_bootstrap import Bootstrap5, SwitchField

app = Flask(__name__)
app.secret_key = 'dev'
Expand Down Expand Up @@ -34,6 +34,7 @@

class ExampleForm(FlaskForm):
"""An example form that contains all the supported bootstrap style form fields."""

date = DateField(description="We'll never share your email with anyone else.") # add help text with `description`
datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw`
datetime_local = DateTimeLocalField()
Expand All @@ -52,8 +53,8 @@ class ExampleForm(FlaskForm):
select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
bio = TextAreaField()
search = SearchField() # will autocapitalize on mobile
title = StringField() # will not autocapitalize on mobile
search = SearchField() # will autocapitalize on mobile
title = StringField() # will not autocapitalize on mobile
secret = PasswordField()
remember = BooleanField('Remember me')
submit = SubmitField()
Expand Down Expand Up @@ -96,7 +97,8 @@ class ContactForm(FlaskForm):

class BootswatchForm(FlaskForm):
"""Form to test Bootswatch."""
#DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.

# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
theme_name = RadioField(
default='default',
choices=[
Expand Down Expand Up @@ -212,7 +214,7 @@ def test_bootswatch():
app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data
flash(f'Render style has been set to {form.theme_name.data}.')
else:
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None:
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None:
form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME']
return render_template('bootswatch.html', form=form)

Expand Down
2 changes: 2 additions & 0 deletions flask_bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def create_app():
.. versionchanged:: 2.0.0
Move common logic to base class ``_Bootstrap``.
"""

bootstrap_version = '4.6.1'
jquery_version = '3.5.1'
popper_version = '1.16.1'
Expand Down Expand Up @@ -276,6 +277,7 @@ def create_app():

.. versionadded:: 2.0.0
"""

bootstrap_version = '5.3.2'
popper_version = '2.11.8'
icons_version = '1.11.3'
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bootstrap4/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def test_deprecate_bootstrap_class(self):

app = Flask(__name__)
with pytest.warns(UserWarning):
bootstrap = Bootstrap(app) # noqa: F841
_ = Bootstrap(app)

def test_deprecate_bootstrap_template_path(self, app, client):
@app.route('/test')
def foo():
def test_render_template_string():
return render_template_string('''
{% from 'bootstrap/utils.html' import render_icon %}
{{ render_icon('heart') }}
Expand Down
8 changes: 4 additions & 4 deletions tests/test_bootstrap4/test_render_breadcrumb_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

def test_render_breadcrumb_item_active(app, client):
@app.route('/not_active_item')
def foo():
def item_foo():
return render_template_string('''
{% from 'bootstrap4/nav.html' import render_breadcrumb_item %}
{{ render_breadcrumb_item('bar', 'Bar') }}
{{ render_breadcrumb_item('item_bar', 'Bar') }}
''')

@app.route('/active_item')
def bar():
def item_bar():
return render_template_string('''
{% from 'bootstrap4/nav.html' import render_breadcrumb_item %}
{{ render_breadcrumb_item('bar', 'Bar') }}
{{ render_breadcrumb_item('item_bar', 'Bar') }}
''')

response = client.get('/not_active_item')
Expand Down
8 changes: 8 additions & 0 deletions tests/test_bootstrap4/test_render_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,18 @@ def test_render_icon_font_config(app, client):
def icon():
return render_template_string('''
{% from 'bootstrap4/utils.html' import render_icon %}
{{ bootstrap.load_icon_font_css() }}
{{ render_icon('heart', font=True) }}
''')

response = client.get('/icon')
data = response.get_data(as_text=True)
assert 'size: 100;' in data
assert 'text-success' in data

# complete test coverage for bootstrap.load_icon_font_css()
app.config['BOOTSTRAP_SERVE_LOCAL'] = not app.config['BOOTSTRAP_SERVE_LOCAL']
response = client.get('/icon')
data = response.get_data(as_text=True)
assert 'size: 100;' in data
assert 'text-success' in data
8 changes: 4 additions & 4 deletions tests/test_bootstrap4/test_render_nav_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

def test_render_nav_item_active(app, client):
@app.route('/active')
def foo():
def item_foo():
return render_template_string('''
{% from 'bootstrap4/nav.html' import render_nav_item %}
{{ render_nav_item('foo', 'Foo') }}
{{ render_nav_item('item_foo', 'Foo') }}
''')

@app.route('/not_active')
def bar():
def item_bar():
return render_template_string('''
{% from 'bootstrap4/nav.html' import render_nav_item %}
{{ render_nav_item('foo', 'Foo') }}
{{ render_nav_item('item_foo', 'Foo') }}
''')

response = client.get('/active')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bootstrap4/test_render_pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Message(db.Model):
def test():
db.drop_all()
db.create_all()
for i in range(100):
for _ in range(100):
msg = Message()
db.session.add(msg)
db.session.commit()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bootstrap4/test_render_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Message(db.Model):
def test():
db.drop_all()
db.create_all()
for i in range(100): # noqa: F841
for _ in range(100):
msg = Message()
db.session.add(msg)
db.session.commit()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bootstrap5/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Message(db.Model):
def test():
db.drop_all()
db.create_all()
for i in range(100): # noqa: F841
for _ in range(100):
msg = Message()
db.session.add(msg)
db.session.commit()
Expand Down
Loading