diff --git a/geocity/apps/submissions/filters.py b/geocity/apps/submissions/filters.py index 04912b8aa..68fd06f04 100644 --- a/geocity/apps/submissions/filters.py +++ b/geocity/apps/submissions/filters.py @@ -2,6 +2,7 @@ from bootstrap_datepicker_plus.widgets import DatePickerInput from django.db.models import Max, Min from django.utils.translation import gettext_lazy as _ +from django_select2.forms import Select2Widget from geocity.apps.accounts.models import AdministrativeEntity from geocity.apps.forms.models import Form, FormCategory @@ -47,14 +48,17 @@ class BaseSubmissionFilterSet(django_filters.FilterSet): forms__administrative_entities = django_filters.filters.ModelChoiceFilter( queryset=_get_administrative_entities_queryset_for_current_user, label=_("Entité administrative"), + widget=Select2Widget(), ) forms__category = django_filters.filters.ModelChoiceFilter( queryset=_get_form_categories_queryset_for_current_user, label=_("Type de demande"), + widget=Select2Widget(), ) forms = django_filters.filters.ModelChoiceFilter( queryset=_get_forms_queryset_for_current_user, label=_("Objet de la demande"), + widget=Select2Widget(), ) created_at = django_filters.DateFilter( field_name="created_at", @@ -120,6 +124,11 @@ class DepartmentSubmissionFilterSet(BaseSubmissionFilterSet): lookup_expr="icontains", label=_("Nom court"), ) + status = django_filters.filters.ChoiceFilter( + choices=models.Submission.STATUS_CHOICES, + label=_("État"), + widget=Select2Widget(), + ) class Meta: model = models.Submission diff --git a/geocity/apps/submissions/forms.py b/geocity/apps/submissions/forms.py index 774a69a30..31c2ebcb6 100644 --- a/geocity/apps/submissions/forms.py +++ b/geocity/apps/submissions/forms.py @@ -26,6 +26,7 @@ from django.utils.safestring import mark_safe from django.utils.text import slugify from django.utils.translation import gettext_lazy as _ +from django_select2.forms import Select2MultipleWidget, Select2Widget from geocity.apps.accounts.models import ( PUBLIC_TYPE_CHOICES, @@ -675,13 +676,14 @@ def get_list_single_field_kwargs(self, field, default_kwargs): return { **default_kwargs, "choices": choices, + "widget": Select2Widget(), } def get_list_multiple_field_kwargs(self, field, default_kwargs): return { **default_kwargs, "choices": [(value, value) for value in field.choices.splitlines()], - "widget": forms.CheckboxSelectMultiple(), + "widget": Select2MultipleWidget(), } def save(self): diff --git a/geocity/settings.py b/geocity/settings.py index 7edc6bd6f..91a9f1924 100644 --- a/geocity/settings.py +++ b/geocity/settings.py @@ -165,7 +165,7 @@ "jazzmin", "jsoneditor", "django_jsonform", - 'django_select2', + "django_select2", # django contrib apps "django.contrib.admin", "django.contrib.auth", diff --git a/geocity/urls.py b/geocity/urls.py index 5ff193985..4a1e9114e 100644 --- a/geocity/urls.py +++ b/geocity/urls.py @@ -47,7 +47,6 @@ path("oauth/", include("oauth2_provider.urls", namespace="oauth2_provider")), path("admin/", admin.site.urls), path("accounts/social/", include("allauth.socialaccount.urls")), - path("select2/", include("django_select2.urls")), ] if settings.ENABLE_2FA: