diff --git a/docs/changelog.rst b/docs/changelog.rst index c49a413c07..57394efb53 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -8,6 +8,7 @@ CHANGELOG **Bug fixes** - Fix OptionalRangeFilter and CustomDateFromToRangeFilter labels translation (fixes #3852) +- Change label filter intervention contractor and filter null value on project contractor detail view (#3820) **Documentation** diff --git a/geotrek/maintenance/filters.py b/geotrek/maintenance/filters.py index 898c398881..672f97ae4f 100644 --- a/geotrek/maintenance/filters.py +++ b/geotrek/maintenance/filters.py @@ -177,7 +177,7 @@ class ProjectFilterSet(StructureRelatedFilterSet): district = ProjectIntersectionFilterDistrict(label=_('District'), lookup_expr='intersects', required=False) area_type = ProjectIntersectionFilterRestrictedAreaType(label=_('Restricted area type'), lookup_expr='intersects', required=False) area = ProjectIntersectionFilterRestrictedArea(label=_('Restricted area'), lookup_expr='intersects', required=False) - contractors = ModelMultipleChoiceFilter(label=_("Intervention contractors"), queryset=Contractor.objects.all(), method='filter_contractors') + contractors = ModelMultipleChoiceFilter(label=_("Contractors"), queryset=Contractor.objects.all(), method='filter_contractors') class Meta(StructureRelatedFilterSet.Meta): model = Project diff --git a/geotrek/maintenance/models.py b/geotrek/maintenance/models.py index d93db6eefa..15e67fbd58 100755 --- a/geotrek/maintenance/models.py +++ b/geotrek/maintenance/models.py @@ -553,7 +553,7 @@ def interventions_csv_display(self): @property def intervention_contractors(self): return self.interventions.aggregate( - intervention_contractors=ArrayAgg('contractors__contractor', distinct=True))['intervention_contractors'] + intervention_contractors=ArrayAgg('contractors__contractor', distinct=True, filter=Q(contractors__contractor__isnull=False)))['intervention_contractors'] @classproperty def intervention_contractors_verbose_name(cls):