Skip to content

Commit

Permalink
Merge pull request #4062 from GeotrekCE/add_feedback_filter
Browse files Browse the repository at this point in the history
馃挮 feat: Add `report` model on Intervention filters in module list (ref #3972)
  • Loading branch information
juggler31 committed Apr 12, 2024
2 parents c8cca89 + a6adbcf commit 6bc4231
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ CHANGELOG
- Fix OptionalRangeFilter and CustomDateFromToRangeFilter labels translation (fixes #3852)
- Fix crash on migrate when db username or dbname contains dash

**Improvements**

- Add `report` model on Intervention filters in module list (#3972)

**Documentation**

- Improve static pages documentation (#4050
Expand Down
7 changes: 6 additions & 1 deletion geotrek/maintenance/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, *args, **kwargs):
class InterventionFilterSet(AltimetryInterventionFilterSet, ZoningFilterSet, StructureRelatedFilterSet):
ON_CHOICES = (('infrastructure', _("Infrastructure")), ('signage', _("Signage")), ('blade', _("Blade")),
('topology', _("Path")), ('trek', _("Trek")), ('poi', _("POI")), ('service', _("Service")),
('trail', _("Trail")))
('trail', _("Trail")), ('report', _("Report")))

if 'geotrek.outdoor' in settings.INSTALLED_APPS:
ON_CHOICES += (('course', _("Outdoor Course")), ('site', _("Outdoor Site")),)
Expand All @@ -157,6 +157,11 @@ class Meta(StructureRelatedFilterSet.Meta):
'status', 'type', 'stake', 'subcontracting', 'project', 'contractors', 'on',
]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Sorted 'ON_CHOICES' here to sort with user language.
self.form.fields["on"].choices = sorted(self.ON_CHOICES, key=lambda modelname: modelname[1])

def filter_year(self, qs, name, values):
conditions = Q()
for value in values:
Expand Down

0 comments on commit 6bc4231

Please sign in to comment.