Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missed css_class to accordion and accordion-group templates #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="accordion-group">
<div class="accordion-group{% if div.css_class %} {{ div.css_class }}{% endif %}">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#{{ div.data_parent }}" href="#{{ div.css_id }}">{{ div.name }}</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion crispy_forms_bootstrap2/templates/bootstrap/accordion.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="accordion" id="{{ accordion.css_id }}">
<div class="accordion{% if accordion.css_class %} {{ accordion.css_class }}{% endif %}" id="{{ accordion.css_id }}">
{{ content|safe }}
</div>
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pytest
pytest-cov
pytest-django
django
django-crispy-forms
django-crispy-forms>=2.3
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
url="https://github.com/django-crispy-forms/crispy-forms-bootstrap2",
license="MIT",
description="Django-crispy-forms bootstrap2 templates",
install_requires=["django-crispy-forms >= 1.8"],
install_requires=["django-crispy-forms >= 2.3"],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
33 changes: 33 additions & 0 deletions tests/test_layout_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,39 @@ def test_accordion_and_accordiongroup(self, settings):
assert html.count('name="password1"') == 1
assert html.count('name="password2"') == 1

def test_accordion_css_class_is_applied(self):
classes = "one two three"
test_form = SampleForm()
test_form.helper = FormHelper()
test_form.helper.form_tag = False
test_form.helper.layout = Layout(
Accordion(
AccordionGroup("one", "first_name"),
css_class=classes,
css_id="super-accordion",
)
)
html = render_crispy_form(test_form)

assert (
html.count('<div class="accordion %s" id="super-accordion"' % classes) == 1
)

def test_accordion_group_css_class_is_applied(self):
classes = "one two three"
test_form = SampleForm()
test_form.helper = FormHelper()
test_form.helper.form_tag = False
test_form.helper.layout = Layout(
Accordion(
AccordionGroup("one", "first_name", css_class=classes),
AccordionGroup("two", "password1", "password2"),
)
)
html = render_crispy_form(test_form)

assert html.count('<div class="accordion-group %s"' % classes) == 1

def test_accordion_active_false_not_rendered(self, settings):
test_form = SampleForm()
test_form.helper = FormHelper()
Expand Down