From e1ce47094c8e95f0a37d7f17becf8c5687251fce Mon Sep 17 00:00:00 2001 From: kosdmit Date: Mon, 22 Jul 2024 13:20:38 +0300 Subject: [PATCH 1/4] Add missed css_class to accordion template --- .../templates/bootstrap3/accordion.html | 2 +- tests/test_layout_objects.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/crispy_bootstrap3/templates/bootstrap3/accordion.html b/crispy_bootstrap3/templates/bootstrap3/accordion.html index 995a9ab..54c66ea 100644 --- a/crispy_bootstrap3/templates/bootstrap3/accordion.html +++ b/crispy_bootstrap3/templates/bootstrap3/accordion.html @@ -1,3 +1,3 @@ -
+
{{ content }}
diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py index 861a7f7..bd59020 100644 --- a/tests/test_layout_objects.py +++ b/tests/test_layout_objects.py @@ -230,6 +230,25 @@ def test_accordion_and_accordiongroup(self): 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('
Date: Mon, 22 Jul 2024 14:51:24 +0300 Subject: [PATCH 2/4] Add missed css_class to accordion-group template --- .../templates/bootstrap3/accordion-group.html | 2 +- tests/test_layout_objects.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/crispy_bootstrap3/templates/bootstrap3/accordion-group.html b/crispy_bootstrap3/templates/bootstrap3/accordion-group.html index 2edaf16..38d963e 100644 --- a/crispy_bootstrap3/templates/bootstrap3/accordion-group.html +++ b/crispy_bootstrap3/templates/bootstrap3/accordion-group.html @@ -1,4 +1,4 @@ -
+

{{ div.name }} diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py index bd59020..ea7bcc7 100644 --- a/tests/test_layout_objects.py +++ b/tests/test_layout_objects.py @@ -210,6 +210,10 @@ def test_inline_radios(self): html = render_crispy_form(test_form) assert html.count('radio-inline"') == 2 + @pytest.mark.xfail( + __version__ < "2.3", + reason="Issue #1395 - AccordionGroup gets unexpected css_class 'active'", + ) def test_accordion_and_accordiongroup(self): test_form = SampleForm() test_form.helper = FormHelper() @@ -249,6 +253,25 @@ def test_accordion_css_class_is_applied(self): == 1 ) + @pytest.mark.xfail( + __version__ < "2.3", + reason="Issue #1395 - AccordionGroup gets unexpected css_class 'active'", + ) + 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('
Date: Mon, 22 Jul 2024 14:54:58 +0300 Subject: [PATCH 3/4] Updated CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e948e..1aadeec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG FOR CRISPY-BOOTSTRAP3 +## TBC + +* Fixed ignoring of `css_class` attribute in `accordion.html` and `accordion-group.html` templates. + ## 2024.1 * Updated supported versions: From 02b037480373ee594f372a74aa6df625767ff88b Mon Sep 17 00:00:00 2001 From: kosdmit Date: Tue, 23 Jul 2024 22:12:20 +0300 Subject: [PATCH 4/4] Add missed css_class to tab template --- CHANGELOG.md | 2 +- crispy_bootstrap3/templates/bootstrap3/layout/tab.html | 2 +- tests/test_layout_objects.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aadeec..41e7e87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## TBC -* Fixed ignoring of `css_class` attribute in `accordion.html` and `accordion-group.html` templates. +* Fixed ignoring of `css_class` attribute in `accordion.html`, `accordion-group.html` and `tab.html` templates. ## 2024.1 diff --git a/crispy_bootstrap3/templates/bootstrap3/layout/tab.html b/crispy_bootstrap3/templates/bootstrap3/layout/tab.html index 007f76a..39cbb6e 100644 --- a/crispy_bootstrap3/templates/bootstrap3/layout/tab.html +++ b/crispy_bootstrap3/templates/bootstrap3/layout/tab.html @@ -1,4 +1,4 @@ - + {{ links }}
diff --git a/tests/test_layout_objects.py b/tests/test_layout_objects.py index ea7bcc7..3da7f05 100644 --- a/tests/test_layout_objects.py +++ b/tests/test_layout_objects.py @@ -330,13 +330,14 @@ def test_tab_and_tab_holder(self): css_class="first-tab-class active", ), Tab("two", "password1", "password2"), + css_class="custom-class", ) ) html = render_crispy_form(test_form) assert ( html.count( - '