Skip to content

Commit

Permalink
Merge branch 'release/5.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dyve committed Apr 21, 2015
2 parents 4bfaddb + 05904c8 commit 0027bc6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ History
-------


5.4.0 (2015-04-21)
++++++++++++++++++

* No more forcing btn-primary when another button class is specified (@takuchanno2)
* Added value option to buttons (@TyVik)
* Switched CDN to //maxcdn.bootstrapcdn.com/bootstrap/3.3.4/ (@djangoic)


5.3.1 (2015-04-08)
++++++++++++++++++

Expand Down
1 change: 1 addition & 0 deletions bootstrap3/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'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 Down
9 changes: 6 additions & 3 deletions bootstrap3/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from .text import text_concat, text_value
from .exceptions import BootstrapError
from .utils import add_css_class, render_tag
from .utils import add_css_class, render_tag, split_css_classes
from .components import render_icon


Expand Down Expand Up @@ -77,7 +77,7 @@ 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):
href='', name=None, value=None):
"""
Render a button with content
"""
Expand All @@ -98,7 +98,8 @@ def render_button(
'empty ("{}" given).'.format(size))
if button_type:
if button_type == 'submit':
classes = add_css_class(classes, 'btn-primary')
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'):
raise BootstrapError(
'Parameter "button_type" should be "submit", "reset", ' +
Expand All @@ -113,6 +114,8 @@ def render_button(
tag = 'button'
if name:
attrs['name'] = name
if value:
attrs['value'] = value
return render_tag(
tag, attrs=attrs, content=text_concat(
icon_content, content, separator=' '))
Expand Down
10 changes: 10 additions & 0 deletions bootstrap3/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(self, *args, **kwargs):
self.show_label = kwargs.get('show_label', True)
self.exclude = kwargs.get('exclude', '')
self.set_required = kwargs.get('set_required', True)
self.set_disabled = kwargs.get('set_disabled', False)
self.size = self.parse_size(kwargs.get('size', ''))
self.horizontal_label_class = kwargs.get(
'horizontal_label_class',
Expand Down Expand Up @@ -94,6 +95,7 @@ def render_forms(self):
show_help=self.show_help,
exclude=self.exclude,
set_required=self.set_required,
set_disabled=self.set_disabled,
size=self.size,
horizontal_label_class=self.horizontal_label_class,
horizontal_field_class=self.horizontal_field_class,
Expand Down Expand Up @@ -149,6 +151,7 @@ def render_fields(self):
show_help=self.show_help,
exclude=self.exclude,
set_required=self.set_required,
set_disabled=self.set_disabled,
size=self.size,
horizontal_label_class=self.horizontal_label_class,
horizontal_field_class=self.horizontal_field_class,
Expand Down Expand Up @@ -243,6 +246,8 @@ def __init__(self, field, *args, **kwargs):
self.set_required = False
self.required_css_class = ''

self.set_disabled = kwargs.get('set_disabled', False)

def restore_widget_attrs(self):
self.widget.attrs = self.initial_attrs

Expand Down Expand Up @@ -274,11 +279,16 @@ def add_required_attrs(self):
if self.set_required and is_widget_required_attribute(self.widget):
self.widget.attrs['required'] = 'required'

def add_disabled_attrs(self):
if self.set_disabled:
self.widget.attrs['disabled'] = 'disabled'

def add_widget_attrs(self):
self.add_class_attrs()
self.add_placeholder_attrs()
self.add_help_attrs()
self.add_required_attrs()
self.add_disabled_attrs()

def list_to_class(self, html, klass):
classes = add_css_class(klass, self.get_size_class())
Expand Down
5 changes: 4 additions & 1 deletion docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The ``BOOTSTRAP3`` dict variable is contains these settings and defaults:
'jquery_url': '//code.jquery.com/jquery.min.js',
# The Bootstrap base URL
'base_url': '//netdna.bootstrapcdn.com/bootstrap/3.3.4/',
'base_url': '//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/',
# The complete URL to the Bootstrap CSS file (None means derive it from base_url)
'css_url': None,
Expand All @@ -44,6 +44,9 @@ The ``BOOTSTRAP3`` dict variable is contains these settings and defaults:
# Set HTML required attribute on required fields
'set_required': True,
# Set HTML disabled attribute on disabled fields
'set_disabled': False,
# Set placeholder attributes to label if no placeholder is provided
'set_placeholder': True,
Expand Down

0 comments on commit 0027bc6

Please sign in to comment.