Skip to content

Commit d846fb4

Browse files
author
Dylan Verheul
committed
Merge pull request zostera#199 from NotSqrt/develop
tox, support for input groups in the widgets
2 parents 31054ba + bbfd84e commit d846fb4

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

bootstrap3/renderers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ def __init__(self, field, *args, **kwargs):
209209
else:
210210
self.placeholder = ''
211211

212-
self.addon_before = kwargs.get('addon_before', '')
213-
self.addon_after = kwargs.get('addon_after', '')
212+
self.addon_before = kwargs.get('addon_before', self.initial_attrs.pop('addon_before', ''))
213+
self.addon_after = kwargs.get('addon_after', self.initial_attrs.pop('addon_after', ''))
214214

215215
# These are set in Django or in the global BOOTSTRAP3 settings, and
216216
# they can be overwritten in the template

bootstrap3/tests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class TestForm(forms.Form):
7373
widget=forms.CheckboxSelectMultiple,
7474
help_text='Check as many as you like.',
7575
)
76+
addon = forms.CharField(
77+
widget=forms.TextInput(attrs={'addon_before': 'before', 'addon_after': 'after'}),
78+
)
7679

7780
required_css_class = 'bootstrap3-req'
7881

@@ -211,6 +214,12 @@ def test_field_names(self):
211214
for field in form:
212215
self.assertIn('name="%s"' % field.name, res)
213216

217+
def test_field_addons(self):
218+
form = TestForm()
219+
res = render_form(form)
220+
self.assertIn('<div class="input-group"><span class="input-group-addon">before</span><input', res)
221+
self.assertIn('/><span class="input-group-addon">after</span></div>', res)
222+
214223
def test_exclude(self):
215224
form = TestForm()
216225
res = render_template(

tox.ini

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Tox (http://codespeak.net/~hpk/tox/) is a tool for running tests
2+
# in multiple virtualenvs. This configuration file will run the
3+
# test suite on all supported python versions. To use it, "pip install tox"
4+
# and then run "tox" from this directory.
5+
6+
[tox]
7+
minversion=1.8.0
8+
envlist =
9+
py26-django14,
10+
py26-django15,
11+
12+
py27-django14,
13+
py27-django15,
14+
py27-django16,
15+
py27-django17,
16+
17+
py32-django15,
18+
py32-django16,
19+
py32-django17,
20+
21+
py33-django15,
22+
py33-django16,
23+
py33-django17,
24+
25+
py34-django15,
26+
py34-django16,
27+
py34-django17,
28+
29+
[testenv]
30+
commands = python manage.py test
31+
deps =
32+
django14: django >=1.4.2,<1.5
33+
django15: django >=1.5,<1.6
34+
django16: django >=1.6,<1.7
35+
django17: django >=1.7,<1.8

0 commit comments

Comments
 (0)