Skip to content

Commit ef1b453

Browse files
committed
Merge branch 'release/9.1.0'
2 parents d5ffb42 + 0acf3da commit ef1b453

File tree

11 files changed

+63
-21
lines changed

11 files changed

+63
-21
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ python:
99
- "3.6"
1010

1111
install:
12+
- sudo apt-get install libgdal-dev
1213
- pip install tox-travis coveralls
1314

1415
script:
1516
- tox
1617

1718
after_success:
18-
- coveralls
19+
- coveralls

HISTORY.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ History
44
-------
55

66

7+
9.1.0
8+
+++++
9+
10+
* Mention `django-bootstrap4 <https://github.com/zostera/django-bootstrap4/>`_ in README
11+
* Rewrite `tox` test matrix to focus on Django releases rather than Python versions
12+
* Add tests for Django master branch (>= 2)
13+
* Add `label` override for `{% bootstrap_field %}`
14+
15+
716
9.0.0 (2017-07-11)
817
++++++++++++++++++
918

README.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Write Django as usual, and let ``django-bootstrap3`` make template output into B
2020
:alt: Number of PyPI downloads per month
2121

2222

23+
Looking for Bootstrap 4?
24+
------------------------
25+
26+
See https://github.com/zostera/django-bootstrap4.
27+
28+
2329
Requirements
2430
------------
2531

@@ -45,8 +51,6 @@ Installation
4551

4652
3. In your templates, load the ``bootstrap3`` library and use the ``bootstrap_*`` tags:
4753

48-
This app will soon require Django 1.8+, python 2.7+. Thanks for understanding.
49-
5054

5155
Example template
5256
----------------

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__ = '9.0.0'
3+
__version__ = '9.1.0'

bootstrap3/renderers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ def __init__(self, field, *args, **kwargs):
255255
self.field_help = text_value(mark_safe(field.help_text)) if self.show_help and field.help_text else ''
256256
self.field_errors = [conditional_escape(text_value(error)) for error in field.errors]
257257

258+
self.label = kwargs.get('label', field.label)
259+
258260
if 'placeholder' in kwargs:
259261
# Find the placeholder in kwargs, even if it's empty
260262
self.placeholder = kwargs['placeholder']
261263
elif get_bootstrap_setting('set_placeholder'):
262264
# If not found, see if we set the label
263-
self.placeholder = field.label
265+
self.placeholder = self.label
264266
else:
265267
# Or just set it to empty
266268
self.placeholder = ''
@@ -390,7 +392,7 @@ def list_to_class(self, html, klass):
390392
def put_inside_label(self, html):
391393
content = '{field} {label}'.format(
392394
field=html,
393-
label=self.field.label,
395+
label=self.label,
394396
)
395397
return render_label(
396398
content=mark_safe(content),
@@ -503,7 +505,7 @@ def get_label(self):
503505
if isinstance(self.widget, CheckboxInput):
504506
label = None
505507
else:
506-
label = self.field.label
508+
label = self.label
507509
if self.layout == 'horizontal' and not label:
508510
return mark_safe('&#160;')
509511
return label

bootstrap3/templatetags/bootstrap3.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,10 @@ def bootstrap_field(*args, **kwargs):
443443
* ``'large'``
444444
445445
placeholder
446-
Sets the placeholder text of a textbox
446+
Set/overwrite the field's placeholder.
447+
448+
label
449+
Overwrite the field's label.
447450
448451
horizontal_label_class
449452
Class used on the label when the ``layout`` is set to ``horizontal``.
@@ -679,7 +682,7 @@ def bootstrap_alert(content, alert_type='info', dismissable=True):
679682
680683
**Example**::
681684
682-
{% bootstrap_alert "Something went wrong" alert_type='error' %}
685+
{% bootstrap_alert "Something went wrong" alert_type='danger' %}
683686
684687
"""
685688
return render_alert(content, alert_type, dismissable)

bootstrap3/tests.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from django.contrib.messages import constants as DEFAULT_MESSAGE_LEVELS
99
from django.forms.formsets import formset_factory
1010
from django.template import engines
11-
from django.test import TestCase
11+
from django.test import TestCase, override_settings
1212

1313
from .bootstrap import DBS3_SET_REQUIRED_SET_DISABLED
1414
from .exceptions import BootstrapError
@@ -131,7 +131,7 @@ class TestFormWithoutRequiredClass(TestForm):
131131

132132
def render_template(text, context=None):
133133
"""
134-
Create a template ``text`` that first loads bootstrap3.
134+
Create a template ``text``
135135
"""
136136
template = engines['django'].from_string(text)
137137
if not context:
@@ -579,6 +579,25 @@ def test_attributes_consistency(self):
579579
attrs = form.fields['addon'].widget.attrs.copy()
580580
self.assertEqual(attrs, form.fields['addon'].widget.attrs)
581581

582+
def test_placeholder(self):
583+
res = render_template_with_form('{% bootstrap_field form.sender %}')
584+
self.assertIn('placeholder="Sender', res)
585+
586+
def test_overwrite_placeholder(self):
587+
res = render_template_with_form('{% bootstrap_field form.sender placeholder="foo" %}')
588+
self.assertIn('placeholder="foo', res)
589+
590+
# If set_placeholder is set, also consider label override for placeholder
591+
res = render_template_with_form('{% bootstrap_field form.sender label="foo" %}')
592+
self.assertNotIn('Sender', res)
593+
self.assertIn('placeholder="foo', res)
594+
self.assertIn('foo</label>', res)
595+
596+
def test_overwrite_label(self):
597+
res = render_template_with_form('{% bootstrap_field form.sender label="foo" %}')
598+
self.assertNotIn('Sender', res)
599+
self.assertIn('foo', res)
600+
582601

583602
class ComponentsTest(TestCase):
584603
def test_icon(self):

docs/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
import os
1515
import sys
1616

17-
import bootstrap3
18-
1917
# If extensions (or modules to document with autodoc) are in another directory,
2018
# add these directories to sys.path here. If the directory is relative to the
2119
# documentation root, use os.path.abspath to make it absolute, like shown here.
@@ -25,6 +23,9 @@
2523
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__))))
2624
os.environ['DJANGO_SETTINGS_MODULE'] = 'testsettings'
2725

26+
# Import bootstrap3 after sys.path has been tweaked
27+
import bootstrap3 # noqa
28+
2829
# -- General configuration -----------------------------------------------------
2930

3031
# If your documentation needs a minimal Sphinx version, state it here.

docs/settings.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ The ``BOOTSTRAP3`` dict variable contains these settings and defaults:
4747
# Set HTML disabled attribute on disabled fields, for Django <= 1.8 only
4848
'set_disabled': False,
4949
50-
# Set placeholder attributes to label if no placeholder is provided
50+
# Set placeholder attributes to label if no placeholder is provided.
51+
# This also considers the 'label' option of {% bootstrap_field %} tags.
5152
'set_placeholder': True,
5253
5354
# Class to indicate required (better to set this in your Django form)

testsettings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
'django.contrib.sessions',
1818
'django.contrib.messages',
1919
'django.contrib.staticfiles',
20-
'django.contrib.gis',
2120

2221
# We test this one
2322
'bootstrap3',
2423
)
2524

26-
MIDDLEWARE_CLASSES = DEFAULT_SETTINGS.MIDDLEWARE_CLASSES
25+
try:
26+
MIDDLEWARE_CLASSES = DEFAULT_SETTINGS.MIDDLEWARE_CLASSES
27+
except AttributeError:
28+
pass
2729

2830
TEMPLATES = [{
2931
'BACKEND': 'django.template.backends.django.DjangoTemplates',

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
minversion = 1.8.0
33
envlist =
44
coverage-clean
5-
py27-django{18,19,110,111}
6-
py33-django{18}
7-
py34-django{18,19,110,111}
8-
py35-django{19,110,111}
9-
py36-django{110,111}
5+
{py27,py33,py34,py35}-django18
6+
{py27,py34,py35}-django{19,110},
7+
{py27,py34,py35,py36}-django111,
8+
{py35,py36}-djangomaster
109
coverage-report
1110
flake8
1211
docs
@@ -19,6 +18,7 @@ deps =
1918
django19: Django>=1.9,<1.10
2019
django110: Django>=1.10,<1.11
2120
django111: Django>=1.11,<2.0
21+
djangomaster: https://github.com/django/django/archive/master.tar.gz
2222

2323
[testenv:coverage-clean]
2424
commands = coverage erase

0 commit comments

Comments
 (0)