From 36e925a0c3bf19d2b34d8bd01e82c6c8f3a6420a Mon Sep 17 00:00:00 2001 From: Christophe Henry Date: Thu, 5 Sep 2024 15:52:48 +0200 Subject: [PATCH] pre-commit --- dsfr/templates/dsfr/widgets/rich_radio.html | 27 +++++++++---------- .../dsfr/widgets/rich_radio_option.html | 17 +++++++----- dsfr/test/test_enums.py | 18 +++++++++---- dsfr/widgets.py | 2 +- example_app/forms.py | 5 +--- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/dsfr/templates/dsfr/widgets/rich_radio.html b/dsfr/templates/dsfr/widgets/rich_radio.html index 37172822d..7570096c1 100644 --- a/dsfr/templates/dsfr/widgets/rich_radio.html +++ b/dsfr/templates/dsfr/widgets/rich_radio.html @@ -1,22 +1,21 @@ {% with id=widget.attrs.id %} -
+
{% for group, options, index in widget.optgroups %} {% if group %} - + {{ group }}
+ {% endif %} + {% for option in options %} + {% include option.template_name with widget=option %} + {% endfor %} + {% if group %} +
{% endif %} - {% for option in options %} - {% include option.template_name with widget=option %} {% endfor %} - {% if group %}
{% endif %} - {% endfor %} -
{% endwith %} + +{% endwith %} diff --git a/dsfr/templates/dsfr/widgets/rich_radio_option.html b/dsfr/templates/dsfr/widgets/rich_radio_option.html index 3c51aeb8b..426f11901 100644 --- a/dsfr/templates/dsfr/widgets/rich_radio_option.html +++ b/dsfr/templates/dsfr/widgets/rich_radio_option.html @@ -1,14 +1,17 @@
- - + + {% if widget.pictogram %}
- {{ widget.pictogram_alt }} + {{ widget.pictogram_alt }}
{% endif %}
-
\ No newline at end of file + diff --git a/dsfr/test/test_enums.py b/dsfr/test/test_enums.py index 5e61a7ca6..d78152d5c 100644 --- a/dsfr/test/test_enums.py +++ b/dsfr/test/test_enums.py @@ -37,12 +37,16 @@ class TestExtendedChoices(ExtendedChoices, IntegerChoices): TEST_1 = { "value": auto(), "additionnal_attribute_1": {"lorem": "ipsum 1"}, - "additionnal_attribute_2": mark_safe("Item 1"), + "additionnal_attribute_2": mark_safe( + "Item 1" + ), # nosec } TEST_2 = { "value": auto(), "additionnal_attribute_1": {"lorem": "ipsum 2"}, - "additionnal_attribute_2": mark_safe("Item 2"), + "additionnal_attribute_2": mark_safe( + "Item 2" + ), # nosec } self.assertEqual( @@ -149,12 +153,16 @@ class TestExtendedChoices(ExtendedChoices, IntegerChoices): TEST_1 = { "value": auto(), "additionnal_attribute_1": {"lorem": "ipsum 1"}, - "additionnal_attribute_2": mark_safe("Item 1"), + "additionnal_attribute_2": mark_safe( + "Item 1" + ), # nosec } TEST_2 = { "value": auto(), "additionnal_attribute_1": {"lorem": "ipsum 2"}, - "additionnal_attribute_2": mark_safe("Item 2"), + "additionnal_attribute_2": mark_safe( + "Item 2" + ), # nosec } @staticmethod @@ -164,4 +172,4 @@ def private_variable_name(name): self.assertEqual( {"Item 1", "Item 2"}, {it.m_additionnal_attribute_2 for it in TestExtendedChoices}, - ) \ No newline at end of file + ) diff --git a/dsfr/widgets.py b/dsfr/widgets.py index 47098f9d9..299708615 100644 --- a/dsfr/widgets.py +++ b/dsfr/widgets.py @@ -1,6 +1,6 @@ from typing import Type -from django.forms.widgets import RadioSelect, ChoiceWidget, CheckboxSelectMultiple +from django.forms.widgets import RadioSelect, ChoiceWidget from dsfr.enums import RichRadioButtonChoices diff --git a/example_app/forms.py b/example_app/forms.py index e74188ee7..5a120b774 100644 --- a/example_app/forms.py +++ b/example_app/forms.py @@ -1,5 +1,4 @@ -import functools -from enum import auto, FlagBoundary +from enum import auto from django import forms from django.db.models import TextChoices @@ -7,10 +6,8 @@ ModelForm, inlineformset_factory, ) # /!\ In order to use formsets -from django.templatetags.static import static from django.db.models import IntegerChoices -from django.utils.functional import keep_lazy_text from dsfr.constants import COLOR_CHOICES, COLOR_CHOICES_ILLUSTRATION from dsfr.enums import RichRadioButtonChoices