Skip to content

Commit 6006c00

Browse files
committed
Merge branch 'release/8.0.0'
2 parents c376478 + d7b6a36 commit 6006c00

File tree

14 files changed

+271
-105
lines changed

14 files changed

+271
-105
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ docs/_build
4949
# Django
5050
local_settings.py
5151

52+
# pyenv
53+
.python-version

HISTORY.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
History
44
-------
55

6+
7+
8.0.0 (2017-01-06)
8+
++++++++++++++++++
9+
10+
* **BREAKING** For Django >= 1.10 Remove everything to do with setting HTML attributes `required` (#337) and `disabled` (#345)
11+
* Add `id` parameter to bootstrap_button (#214)
12+
* Add `set_placeholder` to field and form renderers (#339, thanks @predatell)
13+
* Default button type to `btn-default`
14+
* Add `addon_before_class` and `addon_after_class` (#295, thanks @DanWright91 and others)
15+
* Fix handling of error class (#170)
16+
* No size class for checkboxes (#318, thanks @cybojenix)
17+
* Fix warnings during install (thanks @mfcovington)
18+
* Fix rare RunTimeError when working without database (#346, thanks @Mactory)
19+
* Add subresource integrity to external components (thanks @mfcovington and @Alex131089)
20+
* Several improvements to documentation, tests, and comments. Thanks all!
21+
22+
623
7.1.0 (2016-09-16)
724
++++++++++++++++++
825

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ include CONTRIBUTING.rst
33
include HISTORY.rst
44
include LICENSE
55
include README.rst
6-
recursive-include bootstrap3 *.html *.png *.gif *js *jpg *jpeg *svg *py
7-
recursive-include demo *.html *.png *.gif *js *jpg *jpeg *svg *py
6+
recursive-include bootstrap3 *
7+
recursive-include demo *

bootstrap3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# -*- coding: utf-8 -*-
22

3-
__version__ = '7.1.0'
3+
__version__ = '8.0.0'

bootstrap3/bootstrap.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4-
from django.conf import settings
54
from importlib import import_module
65

6+
from django import VERSION as DJANGO_VERSION
7+
from django.conf import settings
8+
9+
# Do we support set_required and set_disabled?
10+
# See GitHub issues 337 and 345
11+
# TODO: Get rid of this after support for Django 1.8 LTS ends
12+
DBS3_SET_REQUIRED_SET_DISABLED = DJANGO_VERSION[0] < 2 and DJANGO_VERSION[1] < 10
713

814
# Default settings
915
BOOTSTRAP3_DEFAULTS = {
@@ -16,8 +22,7 @@
1622
'include_jquery': False,
1723
'horizontal_label_class': 'col-md-3',
1824
'horizontal_field_class': 'col-md-9',
19-
'set_required': True,
20-
'set_disabled': False,
25+
2126
'set_placeholder': True,
2227
'required_css_class': '',
2328
'error_css_class': 'has-error',
@@ -34,6 +39,12 @@
3439
},
3540
}
3641

42+
if DBS3_SET_REQUIRED_SET_DISABLED:
43+
BOOTSTRAP3_DEFAULTS.update({
44+
'set_required': True,
45+
'set_disabled': False,
46+
})
47+
3748
# Start with a copy of default settings
3849
BOOTSTRAP3 = BOOTSTRAP3_DEFAULTS.copy()
3950

@@ -67,15 +78,15 @@ def javascript_url():
6778
Return the full url to the Bootstrap JavaScript file
6879
"""
6980
return get_bootstrap_setting('javascript_url') or \
70-
bootstrap_url('js/bootstrap.min.js')
81+
bootstrap_url('js/bootstrap.min.js')
7182

7283

7384
def css_url():
7485
"""
7586
Return the full url to the Bootstrap CSS file
7687
"""
7788
return get_bootstrap_setting('css_url') or \
78-
bootstrap_url('css/bootstrap.min.css')
89+
bootstrap_url('css/bootstrap.min.css')
7990

8091

8192
def theme_url():

bootstrap3/components.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33

44
from django.forms.widgets import flatatt
55
from django.utils.safestring import mark_safe
6-
from bootstrap3.utils import render_tag
6+
from bootstrap3.utils import render_tag, add_css_class
77

88
from .text import text_value
99

1010

11-
def render_icon(icon, title=''):
11+
def render_icon(icon, **kwargs):
1212
"""
1313
Render a Bootstrap glyphicon icon
1414
"""
1515
attrs = {
16-
'class': 'glyphicon glyphicon-{icon}'.format(icon=icon),
16+
'class': add_css_class(
17+
'glyphicon glyphicon-{icon}'.format(icon=icon),
18+
kwargs.get('extra_classes', ''),
19+
)
1720
}
21+
title = kwargs.get('title')
1822
if title:
1923
attrs['title'] = title
2024
return render_tag('span', attrs=attrs)

bootstrap3/forms.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212
from .bootstrap import (
1313
get_bootstrap_setting, get_form_renderer, get_field_renderer,
14-
get_formset_renderer
15-
)
16-
from .text import text_concat, text_value
17-
from .exceptions import BootstrapError
18-
from .utils import add_css_class, render_tag, split_css_classes
14+
get_formset_renderer,
15+
DBS3_SET_REQUIRED_SET_DISABLED)
1916
from .components import render_icon
20-
17+
from .exceptions import BootstrapError
18+
from .text import text_concat, text_value
19+
from .utils import add_css_class, render_tag
2120

2221
FORM_GROUP_CLASS = 'form-group'
2322

@@ -77,8 +76,8 @@ def render_label(content, label_for=None, label_class=None, label_title=''):
7776

7877

7978
def render_button(
80-
content, button_type=None, icon=None, button_class='', size='',
81-
href='', name=None, value=None, title=None):
79+
content, button_type=None, icon=None, button_class='btn-default', size='',
80+
href='', name=None, value=None, title=None, extra_classes='', id=''):
8281
"""
8382
Render a button with content
8483
"""
@@ -98,21 +97,21 @@ def render_button(
9897
'Parameter "size" should be "xs", "sm", "lg" or ' +
9998
'empty ("{}" given).'.format(size))
10099
if button_type:
101-
if button_type == 'submit':
102-
if not any([c.startswith('btn-') for c in split_css_classes(classes)]):
103-
classes = add_css_class(classes, 'btn-primary')
104-
elif button_type not in ('reset', 'button', 'link'):
100+
if button_type not in ('submit', 'reset', 'button', 'link'):
105101
raise BootstrapError(
106102
'Parameter "button_type" should be "submit", "reset", ' +
107103
'"button", "link" or empty ("{}" given).'.format(button_type))
108104
attrs['type'] = button_type
105+
classes = add_css_class(classes, extra_classes)
109106
attrs['class'] = classes
110107
icon_content = render_icon(icon) if icon else ''
111108
if href:
112109
attrs['href'] = href
113110
tag = 'a'
114111
else:
115112
tag = 'button'
113+
if id:
114+
attrs['id'] = id
116115
if name:
117116
attrs['name'] = name
118117
if value:
@@ -164,14 +163,14 @@ def is_widget_required_attribute(widget):
164163
"""
165164
Is this widget required?
166165
"""
167-
if not get_bootstrap_setting('set_required'):
166+
if DBS3_SET_REQUIRED_SET_DISABLED and not get_bootstrap_setting('set_required'):
168167
return False
169168
if not widget.is_required:
170169
return False
171170
if isinstance(
172171
widget, (
173-
AdminFileWidget, HiddenInput, FileInput,
174-
CheckboxInput, CheckboxSelectMultiple)):
172+
AdminFileWidget, HiddenInput, FileInput,
173+
CheckboxInput, CheckboxSelectMultiple)):
175174
return False
176175
return True
177176

0 commit comments

Comments
 (0)