Skip to content

Commit

Permalink
Merge branch 'release/8.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Jan 6, 2017
2 parents c376478 + d7b6a36 commit 6006c00
Show file tree
Hide file tree
Showing 14 changed files with 271 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ docs/_build
# Django
local_settings.py

# pyenv
.python-version
17 changes: 17 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
History
-------


8.0.0 (2017-01-06)
++++++++++++++++++

* **BREAKING** For Django >= 1.10 Remove everything to do with setting HTML attributes `required` (#337) and `disabled` (#345)
* Add `id` parameter to bootstrap_button (#214)
* Add `set_placeholder` to field and form renderers (#339, thanks @predatell)
* Default button type to `btn-default`
* Add `addon_before_class` and `addon_after_class` (#295, thanks @DanWright91 and others)
* Fix handling of error class (#170)
* No size class for checkboxes (#318, thanks @cybojenix)
* Fix warnings during install (thanks @mfcovington)
* Fix rare RunTimeError when working without database (#346, thanks @Mactory)
* Add subresource integrity to external components (thanks @mfcovington and @Alex131089)
* Several improvements to documentation, tests, and comments. Thanks all!


7.1.0 (2016-09-16)
++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include bootstrap3 *.html *.png *.gif *js *jpg *jpeg *svg *py
recursive-include demo *.html *.png *.gif *js *jpg *jpeg *svg *py
recursive-include bootstrap3 *
recursive-include demo *
2 changes: 1 addition & 1 deletion bootstrap3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = '7.1.0'
__version__ = '8.0.0'
21 changes: 16 additions & 5 deletions bootstrap3/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from importlib import import_module

from django import VERSION as DJANGO_VERSION
from django.conf import settings

# Do we support set_required and set_disabled?
# See GitHub issues 337 and 345
# TODO: Get rid of this after support for Django 1.8 LTS ends
DBS3_SET_REQUIRED_SET_DISABLED = DJANGO_VERSION[0] < 2 and DJANGO_VERSION[1] < 10

# Default settings
BOOTSTRAP3_DEFAULTS = {
Expand All @@ -16,8 +22,7 @@
'include_jquery': False,
'horizontal_label_class': 'col-md-3',
'horizontal_field_class': 'col-md-9',
'set_required': True,
'set_disabled': False,

'set_placeholder': True,
'required_css_class': '',
'error_css_class': 'has-error',
Expand All @@ -34,6 +39,12 @@
},
}

if DBS3_SET_REQUIRED_SET_DISABLED:
BOOTSTRAP3_DEFAULTS.update({
'set_required': True,
'set_disabled': False,
})

# Start with a copy of default settings
BOOTSTRAP3 = BOOTSTRAP3_DEFAULTS.copy()

Expand Down Expand Up @@ -67,15 +78,15 @@ def javascript_url():
Return the full url to the Bootstrap JavaScript file
"""
return get_bootstrap_setting('javascript_url') or \
bootstrap_url('js/bootstrap.min.js')
bootstrap_url('js/bootstrap.min.js')


def css_url():
"""
Return the full url to the Bootstrap CSS file
"""
return get_bootstrap_setting('css_url') or \
bootstrap_url('css/bootstrap.min.css')
bootstrap_url('css/bootstrap.min.css')


def theme_url():
Expand Down
10 changes: 7 additions & 3 deletions bootstrap3/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@

from django.forms.widgets import flatatt
from django.utils.safestring import mark_safe
from bootstrap3.utils import render_tag
from bootstrap3.utils import render_tag, add_css_class

from .text import text_value


def render_icon(icon, title=''):
def render_icon(icon, **kwargs):
"""
Render a Bootstrap glyphicon icon
"""
attrs = {
'class': 'glyphicon glyphicon-{icon}'.format(icon=icon),
'class': add_css_class(
'glyphicon glyphicon-{icon}'.format(icon=icon),
kwargs.get('extra_classes', ''),
)
}
title = kwargs.get('title')
if title:
attrs['title'] = title
return render_tag('span', attrs=attrs)
Expand Down
29 changes: 14 additions & 15 deletions bootstrap3/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

from .bootstrap import (
get_bootstrap_setting, get_form_renderer, get_field_renderer,
get_formset_renderer
)
from .text import text_concat, text_value
from .exceptions import BootstrapError
from .utils import add_css_class, render_tag, split_css_classes
get_formset_renderer,
DBS3_SET_REQUIRED_SET_DISABLED)
from .components import render_icon

from .exceptions import BootstrapError
from .text import text_concat, text_value
from .utils import add_css_class, render_tag

FORM_GROUP_CLASS = 'form-group'

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


def render_button(
content, button_type=None, icon=None, button_class='', size='',
href='', name=None, value=None, title=None):
content, button_type=None, icon=None, button_class='btn-default', size='',
href='', name=None, value=None, title=None, extra_classes='', id=''):
"""
Render a button with content
"""
Expand All @@ -98,21 +97,21 @@ def render_button(
'Parameter "size" should be "xs", "sm", "lg" or ' +
'empty ("{}" given).'.format(size))
if button_type:
if button_type == 'submit':
if not any([c.startswith('btn-') for c in split_css_classes(classes)]):
classes = add_css_class(classes, 'btn-primary')
elif button_type not in ('reset', 'button', 'link'):
if button_type not in ('submit', 'reset', 'button', 'link'):
raise BootstrapError(
'Parameter "button_type" should be "submit", "reset", ' +
'"button", "link" or empty ("{}" given).'.format(button_type))
attrs['type'] = button_type
classes = add_css_class(classes, extra_classes)
attrs['class'] = classes
icon_content = render_icon(icon) if icon else ''
if href:
attrs['href'] = href
tag = 'a'
else:
tag = 'button'
if id:
attrs['id'] = id
if name:
attrs['name'] = name
if value:
Expand Down Expand Up @@ -164,14 +163,14 @@ def is_widget_required_attribute(widget):
"""
Is this widget required?
"""
if not get_bootstrap_setting('set_required'):
if DBS3_SET_REQUIRED_SET_DISABLED and not get_bootstrap_setting('set_required'):
return False
if not widget.is_required:
return False
if isinstance(
widget, (
AdminFileWidget, HiddenInput, FileInput,
CheckboxInput, CheckboxSelectMultiple)):
AdminFileWidget, HiddenInput, FileInput,
CheckboxInput, CheckboxSelectMultiple)):
return False
return True

Expand Down

0 comments on commit 6006c00

Please sign in to comment.