diff --git a/docs/changelog.rst b/docs/changelog.rst index 87c8183fc6..81dc70d9a0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,12 +5,17 @@ CHANGELOG 2.111.0+dev (XXXX-XX-XX) ---------------------------- +**Performances** + +- Delay loading filter form in List Views (refs #2967) + **Documentation** - Update theme color - Fix typo in documentation - Update and homogenize README.rst + 2.111.0 (2024-12-05) ---------------------------- diff --git a/geotrek/common/static/common/main.js b/geotrek/common/static/common/main.js deleted file mode 100644 index 5028853b65..0000000000 --- a/geotrek/common/static/common/main.js +++ /dev/null @@ -1,5 +0,0 @@ -$(window).on('entity:view:list', function () { - // Move all topology-filters to separate tab - $('#mainfilter .right-filter').parent('p') - .detach().appendTo('#mainfilter > .right'); -}); diff --git a/geotrek/common/templates/common/common_extrabody_fragment.html b/geotrek/common/templates/common/common_extrabody_fragment.html deleted file mode 100644 index ec8c160130..0000000000 --- a/geotrek/common/templates/common/common_extrabody_fragment.html +++ /dev/null @@ -1,2 +0,0 @@ -{% load static %} -<script type="text/javascript" src="{% static "common/main.js" %}"></script> diff --git a/geotrek/common/views.py b/geotrek/common/views.py index 2f2aab8edd..70fa21ea03 100644 --- a/geotrek/common/views.py +++ b/geotrek/common/views.py @@ -43,7 +43,7 @@ from mapentity import views as mapentity_views from mapentity.helpers import api_bbox from mapentity.registry import app_settings, registry -from mapentity.views import MapEntityList +from mapentity.views import MapEntityList, MapEntityFilter from paperclip import settings as settings_paperclip from paperclip.views import _handle_attachment_form from rest_framework import mixins, viewsets @@ -292,14 +292,19 @@ def import_update_json(request): class HDViewPointList(MapEntityList): queryset = HDViewPoint.objects.all() - filterform = HDViewPointFilterSet columns = ['id', 'title'] +class HDViewPointFilter(MapEntityFilter): + model = HDViewPoint + filterset_class = HDViewPointFilterSet + + class HDViewPointViewSet(GeotrekMapentityViewSet): model = HDViewPoint serializer_class = HDViewPointSerializer geojson_serializer_class = HDViewPointGeoJSONSerializer + filterset_class = HDViewPointFilterSet mapentity_list_class = HDViewPointList def get_queryset(self): diff --git a/geotrek/core/views.py b/geotrek/core/views.py index 5154f27c85..cc92628638 100644 --- a/geotrek/core/views.py +++ b/geotrek/core/views.py @@ -19,7 +19,7 @@ from django.views.generic.detail import BaseDetailView from mapentity.serializers import GPXSerializer from mapentity.views import (MapEntityList, MapEntityDetail, MapEntityDocument, MapEntityCreate, MapEntityUpdate, - MapEntityDelete, MapEntityFormat, LastModifiedMixin) + MapEntityDelete, MapEntityFormat, LastModifiedMixin, MapEntityFilter) from rest_framework.decorators import action from rest_framework.renderers import JSONRenderer, BrowsableAPIRenderer from rest_framework.response import Response @@ -60,14 +60,19 @@ def get_initial(self): class PathList(CustomColumnsMixin, MapEntityList): queryset = Path.objects.all() - filterform = PathFilterSet mandatory_columns = ['id', 'checkbox', 'name', 'length'] default_extra_columns = ['length_2d'] unorderable_columns = ['checkbox'] searchable_columns = ['id', 'name'] +class PathFilter(MapEntityFilter): + model = Path + filterset_class = PathFilterSet + + class PathFormatList(MapEntityFormat, PathList): + filterset_class = PathFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'valid', 'visible', 'name', 'comments', 'departure', 'arrival', @@ -343,13 +348,18 @@ class CertificationTrailMixin(FormsetMixin): class TrailList(CustomColumnsMixin, MapEntityList): queryset = Trail.objects.existing() - filterform = TrailFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['departure', 'arrival', 'length'] searchable_columns = ['id', 'name', 'departure', 'arrival', ] +class TrailFilter(MapEntityFilter): + model = Trail + filterset_class = TrailFilterSet + + class TrailFormatList(MapEntityFormat, TrailList): + filterset_class = TrailFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'name', 'comments', diff --git a/geotrek/diving/views.py b/geotrek/diving/views.py index 9fcb84fa98..ffb9e3ffda 100644 --- a/geotrek/diving/views.py +++ b/geotrek/diving/views.py @@ -1,6 +1,6 @@ from django.conf import settings from django.contrib.gis.db.models.functions import Transform -from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityMapImage, +from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityFilter, MapEntityDetail, MapEntityMapImage, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete) from geotrek.authent.decorators import same_structure_required @@ -15,7 +15,6 @@ class DiveList(CustomColumnsMixin, FlattenPicturesMixin, MapEntityList): - filterform = DiveFilterSet queryset = Dive.objects.existing() mandatory_columns = ['id', 'name'] default_extra_columns = ['levels', 'thumbnail'] @@ -23,7 +22,13 @@ class DiveList(CustomColumnsMixin, FlattenPicturesMixin, MapEntityList): searchable_columns = ['id', 'name'] +class DiveFilter(MapEntityFilter): + model = Dive + filterset_class = DiveFilterSet + + class DiveFormatList(MapEntityFormat, DiveList): + filterset_class = DiveFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'eid', 'structure', 'name', 'departure', diff --git a/geotrek/feedback/views.py b/geotrek/feedback/views.py index 7e4ce84200..09cf2524cf 100644 --- a/geotrek/feedback/views.py +++ b/geotrek/feedback/views.py @@ -33,7 +33,6 @@ class ReportList(CustomColumnsMixin, mapentity_views.MapEntityList): .prefetch_related("attachments") ) model = feedback_models.Report - filterform = ReportEmailFilterSet mandatory_columns = ['id', 'eid', 'activity'] default_extra_columns = ['category', 'status', 'date_update'] searchable_columns = ['id', 'eid'] @@ -45,6 +44,11 @@ def get_queryset(self): qs = qs.filter(assigned_user=self.request.user) return qs + +class ReportFilter(mapentity_views.MapEntityFilter): + model = feedback_models.Report + filterset_class = ReportEmailFilterSet + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) # Remove email from available filters in workflow mode for supervisors @@ -54,12 +58,13 @@ def get_context_data(self, **kwargs): self._filterform.helper = FormHelper() self._filterform.helper.field_class = 'form-control-sm' self._filterform.helper.submit = None - context['filterform'] = self._filterform + context['filter'] = self._filterform return context class ReportFormatList(mapentity_views.MapEntityFormat, ReportList): mandatory_columns = ['id', 'email'] + filterset_class = ReportEmailFilterSet default_extra_columns = [ 'activity', 'comment', 'category', 'problem_magnitude', 'status', 'related_trek', diff --git a/geotrek/infrastructure/views.py b/geotrek/infrastructure/views.py index 452834ca0e..29e9896a11 100755 --- a/geotrek/infrastructure/views.py +++ b/geotrek/infrastructure/views.py @@ -8,6 +8,7 @@ MapEntityDocument, MapEntityFormat, MapEntityList, + MapEntityFilter, MapEntityUpdate, ) @@ -25,13 +26,18 @@ class InfrastructureList(CustomColumnsMixin, MapEntityList): queryset = Infrastructure.objects.existing() - filterform = InfrastructureFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['type', 'conditions', 'cities'] searchable_columns = ['id', 'name'] +class InfrastructureFilter(MapEntityFilter): + model = Infrastructure + filterset_class = InfrastructureFilterSet + + class InfrastructureFormatList(MapEntityFormat, InfrastructureList): + filterset_class = InfrastructureFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'id', 'name', 'type', 'conditions', 'description', 'accessibility', diff --git a/geotrek/land/views.py b/geotrek/land/views.py index c12103828c..3e28ac8fd0 100644 --- a/geotrek/land/views.py +++ b/geotrek/land/views.py @@ -1,6 +1,6 @@ from django.conf import settings from django.contrib.gis.db.models.functions import Transform -from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityDocument, +from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityFilter, MapEntityDetail, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete) from geotrek.common.mixins.views import CustomColumnsMixin @@ -22,12 +22,17 @@ class PhysicalEdgeList(CustomColumnsMixin, CreateFromTopologyMixin, MapEntityList): queryset = PhysicalEdge.objects.existing() - filterform = PhysicalEdgeFilterSet mandatory_columns = ['id', 'physical_type'] default_extra_columns = ['length', 'length_2d'] +class PhysicalEdgeFilter(MapEntityFilter): + model = PhysicalEdge + filterset_class = PhysicalEdgeFilterSet + + class PhysicalEdgeFormatList(MapEntityFormat, PhysicalEdgeList): + filterset_class = PhysicalEdgeFilterSet mandatory_columns = ['id', 'physical_type'] default_extra_columns = [ 'date_insert', 'date_update', @@ -77,12 +82,17 @@ def get_queryset(self): class LandEdgeList(CustomColumnsMixin, MapEntityList): queryset = LandEdge.objects.existing() - filterform = LandEdgeFilterSet mandatory_columns = ['id', 'land_type'] default_extra_columns = ['length', 'length_2d'] +class LandEdgeFilter(MapEntityFilter): + model = LandEdge + filterset_class = LandEdgeFilterSet + + class LandEdgeFormatList(MapEntityFormat, LandEdgeList): + filterset_class = LandEdgeFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'land_type', 'owner', 'agreement', 'date_insert', 'date_update', @@ -130,12 +140,17 @@ def get_queryset(self): class CirculationEdgeList(CustomColumnsMixin, MapEntityList): queryset = CirculationEdge.objects.existing() - filterform = CirculationEdgeFilterSet mandatory_columns = ['id', 'circulation_type', 'authorization_type'] default_extra_columns = ['length', 'length_2d'] +class CirculationEdgeFilter(MapEntityFilter): + model = CirculationEdge + filterset_class = CirculationEdgeFilterSet + + class CirculationEdgeFormatList(MapEntityFormat, CirculationEdgeList): + filterset_class = CirculationEdgeFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'circulation_type', 'authorization_type', 'date_insert', 'date_update', @@ -183,12 +198,17 @@ def get_queryset(self): class CompetenceEdgeList(CustomColumnsMixin, MapEntityList): queryset = CompetenceEdge.objects.existing() - filterform = CompetenceEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = ['length', 'length_2d'] +class CompetenceEdgeFilter(MapEntityFilter): + model = CompetenceEdge + filterset_class = CompetenceEdgeFilterSet + + class CompetenceEdgeFormatList(MapEntityFormat, CompetenceEdgeList): + filterset_class = CompetenceEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = [ 'date_insert', 'date_update', @@ -236,12 +256,17 @@ def get_queryset(self): class WorkManagementEdgeList(CustomColumnsMixin, MapEntityList): queryset = WorkManagementEdge.objects.existing() - filterform = WorkManagementEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = ['length', 'length_2d'] +class WorkManagementEdgeFilter(MapEntityFilter): + model = WorkManagementEdge + filterset_class = WorkManagementEdgeFilterSet + + class WorkManagementEdgeFormatList(MapEntityFormat, WorkManagementEdgeList): + filterset_class = WorkManagementEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = [ 'date_insert', 'date_update', 'cities', 'districts', 'areas', 'uuid', 'length_2d' @@ -288,12 +313,17 @@ def get_queryset(self): class SignageManagementEdgeList(CustomColumnsMixin, MapEntityList): queryset = SignageManagementEdge.objects.existing() - filterform = SignageManagementEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = ['length', 'length_2d'] +class SignageManagementEdgeFilter(MapEntityFilter): + model = SignageManagementEdge + filterset_class = SignageManagementEdgeFilterSet + + class SignageManagementEdgeFormatList(MapEntityFormat, SignageManagementEdgeList): + filterset_class = SignageManagementEdgeFilterSet mandatory_columns = ['id', 'organization'] default_extra_columns = [ 'date_insert', 'date_update', 'cities', 'districts', 'areas', 'uuid', 'length_2d' diff --git a/geotrek/maintenance/static/maintenance/main.js b/geotrek/maintenance/static/maintenance/main.js index 29372bd072..df97ce7696 100644 --- a/geotrek/maintenance/static/maintenance/main.js +++ b/geotrek/maintenance/static/maintenance/main.js @@ -48,7 +48,7 @@ $(window).on('entity:view:add', function (e, data) { }; }); -$(window).on('entity:view:list', function (e, data) { +$(window).on('entity:view:filter', function (e, data) { if (data.modelname === "intervention"){ setDatePickerConfig('#id_begin_date_0, #id_begin_date_1, #id_end_date_0, #id_end_date_1'); }; diff --git a/geotrek/maintenance/views.py b/geotrek/maintenance/views.py index efc544b911..37128df704 100755 --- a/geotrek/maintenance/views.py +++ b/geotrek/maintenance/views.py @@ -5,7 +5,7 @@ from django.db.models import Subquery, OuterRef, Sum from django.db.models.expressions import Value from django.utils.translation import gettext_lazy as _ -from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityDocument, +from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityFilter, MapEntityDetail, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete) from geotrek.altimetry.models import AltimetryMixin @@ -34,14 +34,19 @@ def _normalize_annotation_column_name(col_name): class InterventionList(CustomColumnsMixin, MapEntityList): queryset = Intervention.objects.existing() - filterform = InterventionFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['begin_date', 'end_date', 'type', 'target', 'status', 'stake'] searchable_columns = ['id', 'name'] unorderable_columns = ['target'] +class InterventionFilter(MapEntityFilter): + model = Intervention + filterset_class = InterventionFilterSet + + class InterventionFormatList(MapEntityFormat, InterventionList): + filterset_class = InterventionFilterSet @classmethod def build_cost_column_name(cls, job_name): @@ -190,14 +195,19 @@ def get_queryset(self): class ProjectList(CustomColumnsMixin, MapEntityList): queryset = Project.objects.existing() - filterform = ProjectFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['period', 'type', 'domain'] searchable_columns = ['id', 'name'] unorderable_columns = ['period', ] +class ProjectFilter(MapEntityFilter): + model = Project + filterset_class = ProjectFilterSet + + class ProjectFormatList(MapEntityFormat, ProjectList): + filterset_class = ProjectFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'name', 'period', 'type', 'domain', 'constraint', 'global_cost', diff --git a/geotrek/outdoor/views.py b/geotrek/outdoor/views.py index d44c0c407f..1b2cf10816 100644 --- a/geotrek/outdoor/views.py +++ b/geotrek/outdoor/views.py @@ -3,7 +3,7 @@ from django.db.models import Prefetch from geotrek.common.models import HDViewPoint from mapentity.helpers import alphabet_enumeration -from mapentity.views import (MapEntityList, MapEntityDetail, MapEntityDocument, MapEntityCreate, +from mapentity.views import (MapEntityList, MapEntityFilter, MapEntityDetail, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete, MapEntityFormat) from geotrek.authent.decorators import same_structure_required @@ -18,12 +18,16 @@ class SiteList(CustomColumnsMixin, MapEntityList): queryset = Site.objects.all() - filterform = SiteFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['super_practices', 'date_update'] searchable_columns = ['id', 'name'] +class SiteFilter(MapEntityFilter): + model = Site + filterset_class = SiteFilterSet + + class SiteDetail(CompletenessMixin, MapEntityDetail): queryset = Site.objects.all().prefetch_related( Prefetch('view_points', @@ -104,6 +108,7 @@ class SiteMarkupPublic(SiteDocumentPublicMixin, MarkupPublic): class SiteFormatList(MapEntityFormat, SiteList): + filterset_class = SiteFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'name', 'practice', 'description', @@ -130,12 +135,16 @@ def get_queryset(self): class CourseList(CustomColumnsMixin, MapEntityList): queryset = Course.objects.select_related('type').prefetch_related('parent_sites').all() - filterform = CourseFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['parent_sites', 'date_update'] searchable_columns = ['id', 'name'] +class CourseFilter(MapEntityFilter): + model = Course + filterset_class = CourseFilterSet + + class CourseDetail(CompletenessMixin, MapEntityDetail): queryset = Course.objects.prefetch_related('type').all() @@ -208,6 +217,7 @@ class CourseMarkupPublic(CourseDocumentPublicMixin, MarkupPublic): class CourseFormatList(MapEntityFormat, CourseList): + filterset_class = CourseFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'name', 'parent_sites', 'description', 'advice', 'equipment', 'accessibility', diff --git a/geotrek/sensitivity/views.py b/geotrek/sensitivity/views.py index 959290bd75..c4460712ba 100644 --- a/geotrek/sensitivity/views.py +++ b/geotrek/sensitivity/views.py @@ -9,7 +9,7 @@ from django.views.generic import ListView from django.views.generic.detail import BaseDetailView from mapentity.views import (MapEntityCreate, MapEntityUpdate, MapEntityList, MapEntityDetail, - MapEntityDelete, MapEntityFormat, LastModifiedMixin) + MapEntityDelete, MapEntityFormat, LastModifiedMixin, MapEntityFilter) from geotrek.authent.decorators import same_structure_required from geotrek.common.mixins.views import CustomColumnsMixin @@ -26,12 +26,17 @@ class SensitiveAreaList(CustomColumnsMixin, MapEntityList): queryset = SensitiveArea.objects.existing() - filterform = SensitiveAreaFilterSet mandatory_columns = ['id', 'species'] default_extra_columns = ['category'] +class SensitiveAreaFilter(MapEntityFilter): + model = SensitiveArea + filterset_class = SensitiveAreaFilterSet + + class SensitiveAreaFormatList(MapEntityFormat, SensitiveAreaList): + filterset_class = SensitiveAreaFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'species', 'published', 'description', 'contact', 'radius', 'pretty_period', 'pretty_practices', diff --git a/geotrek/signage/views.py b/geotrek/signage/views.py index 68e5e9420f..2ebed3f769 100755 --- a/geotrek/signage/views.py +++ b/geotrek/signage/views.py @@ -4,7 +4,7 @@ from django.contrib.gis.db.models.functions import Transform from django.http import HttpResponse from django.utils.functional import classproperty -from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, +from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityFilter, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete) from geotrek.authent.decorators import same_structure_required @@ -28,13 +28,18 @@ class LineMixin(FormsetMixin): class SignageList(CustomColumnsMixin, MapEntityList): queryset = Signage.objects.existing() - filterform = SignageFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['code', 'type', 'conditions'] searchable_columns = ['id', 'name', 'code'] +class SignageFilter(MapEntityFilter): + model = Signage + filterset_class = SignageFilterSet + + class SignageFormatList(MapEntityFormat, SignageList): + filterset_class = SignageFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'name', 'code', 'type', 'conditions', 'description', @@ -161,7 +166,6 @@ def get_success_url(self): class BladeList(CustomColumnsMixin, MapEntityList): queryset = Blade.objects.existing() - filterform = BladeFilterSet mandatory_columns = ['id', 'number'] default_extra_columns = ['type', 'color', 'direction'] searchable_columns = ['id', 'number'] @@ -180,7 +184,13 @@ def columns(cls): return columns +class BladeFilter(MapEntityFilter): + model = Blade + filterset_class = BladeFilterSet + + class BladeFormatList(MapEntityFormat, BladeList): + filterset_class = BladeFilterSet mandatory_columns = ['id'] default_extra_columns = ['city', 'signage', 'printedelevation', 'bladecode', 'type', 'color', 'direction', 'conditions', 'coordinates'] diff --git a/geotrek/tourism/static/tourism/main.js b/geotrek/tourism/static/tourism/main.js index 73f4020252..54d6ff0215 100644 --- a/geotrek/tourism/static/tourism/main.js +++ b/geotrek/tourism/static/tourism/main.js @@ -87,7 +87,7 @@ $(window).on('entity:map', function (e, data) { }); -$(window).on('entity:view:list', function (e, data) { +$(window).on('entity:view:filter', function (e, data) { // Date picker $('#id_before, #id_after').datepicker({ diff --git a/geotrek/tourism/views.py b/geotrek/tourism/views.py index 693d06a4c4..cf349fdc96 100644 --- a/geotrek/tourism/views.py +++ b/geotrek/tourism/views.py @@ -10,7 +10,7 @@ from django.utils.decorators import method_decorator from django.utils.html import escape from django.views.generic import CreateView -from mapentity.views import (MapEntityCreate, MapEntityUpdate, MapEntityList, MapEntityDetail, +from mapentity.views import (MapEntityCreate, MapEntityUpdate, MapEntityList, MapEntityDetail, MapEntityFilter, MapEntityDelete, MapEntityFormat, MapEntityDocument) from rest_framework import permissions as rest_permissions, viewsets @@ -34,7 +34,6 @@ class TouristicContentList(CustomColumnsMixin, MapEntityList): queryset = TouristicContent.objects.existing() - filterform = TouristicContentFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['category'] searchable_columns = ['id', 'name'] @@ -45,7 +44,13 @@ def categories_list(self): return TouristicContentCategory.objects.filter(pk__in=used) +class TouristicContentFilter(MapEntityFilter): + model = TouristicContent + filterset_class = TouristicContentFilterSet + + class TouristicContentFormatList(MapEntityFormat, TouristicContentList): + filterset_class = TouristicContentFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'eid', 'name', 'category', 'type1', 'type2', 'description_teaser', @@ -158,13 +163,18 @@ def get_queryset(self): class TouristicEventList(CustomColumnsMixin, MapEntityList): queryset = TouristicEvent.objects.existing() - filterform = TouristicEventFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['type', 'begin_date', 'end_date'] searchable_columns = ['id', 'name'] +class TouristicEventFilter(MapEntityFilter): + model = TouristicEvent + filterset_class = TouristicEventFilterSet + + class TouristicEventFormatList(MapEntityFormat, TouristicEventList): + filterset_class = TouristicEventFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'eid', 'name', 'type', 'description_teaser', 'description', 'themes', diff --git a/geotrek/trekking/views.py b/geotrek/trekking/views.py index a50738da35..6c4bb821b2 100755 --- a/geotrek/trekking/views.py +++ b/geotrek/trekking/views.py @@ -10,7 +10,7 @@ from django.views.generic import CreateView from django.views.generic.detail import BaseDetailView from mapentity.helpers import alphabet_enumeration -from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityMapImage, +from mapentity.views import (MapEntityList, MapEntityFormat, MapEntityDetail, MapEntityMapImage, MapEntityFilter, MapEntityDocument, MapEntityCreate, MapEntityUpdate, MapEntityDelete, LastModifiedMixin) from rest_framework import permissions as rest_permissions, viewsets @@ -52,7 +52,6 @@ def get_queryset(self): class TrekList(CustomColumnsMixin, FlattenPicturesMixin, MapEntityList): - filterform = TrekFilterSet queryset = Trek.objects.existing() mandatory_columns = ['id', 'name'] default_extra_columns = ['duration', 'difficulty', 'departure', 'thumbnail'] @@ -60,7 +59,13 @@ class TrekList(CustomColumnsMixin, FlattenPicturesMixin, MapEntityList): searchable_columns = ['id', 'name', 'departure', 'arrival'] +class TrekFilter(MapEntityFilter): + model = Trek + filterset_class = TrekFilterSet + + class TrekFormatList(MapEntityFormat, TrekList): + filterset_class = TrekFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = [ 'eid', 'eid2', 'structure', 'departure', 'arrival', 'duration', 'duration_pretty', 'description', @@ -229,14 +234,19 @@ def get_queryset(self): class POIList(CustomColumnsMixin, FlattenPicturesMixin, MapEntityList): queryset = POI.objects.existing() - filterform = POIFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = ['type', 'thumbnail'] unorderable_columns = ['thumbnail'] searchable_columns = ['id', 'name', ] +class POIFilter(MapEntityFilter): + model = POI + filterset_class = POIFilterSet + + class POIFormatList(MapEntityFormat, POIList): + filterset_class = POIFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'structure', 'eid', 'name', 'type', 'description', 'treks', @@ -386,13 +396,18 @@ def get_queryset(self): class ServiceList(CustomColumnsMixin, MapEntityList): queryset = Service.objects.existing() - filterform = ServiceFilterSet mandatory_columns = ['id', 'name'] default_extra_columns = [] searchable_columns = ['id'] +class ServiceFilter(MapEntityFilter): + model = Service + filterset_class = ServiceFilterSet + + class ServiceFormatList(MapEntityFormat, ServiceList): + filterset_class = ServiceFilterSet mandatory_columns = ['id'] default_extra_columns = [ 'id', 'eid', 'type', 'uuid', diff --git a/geotrek/zoning/static/zoning/main.js b/geotrek/zoning/static/zoning/main.js index 576c6da8e7..1ca622fb7b 100644 --- a/geotrek/zoning/static/zoning/main.js +++ b/geotrek/zoning/static/zoning/main.js @@ -58,9 +58,7 @@ function refresh_selector_with_areas($select, areas, selected) { $select.trigger('chosen:updated'); } -$(window).on('entity:view:list', function () { - // Move all topology-filters to separate tab - $('#mainfilter .right-filter').parent('p').detach().appendTo('#mainfilter > .right'); +$(window).on('entity:view:filter', function () { // Dynamic area filters $('#id_area_type').change(function () { // Parse area data diff --git a/requirements.txt b/requirements.txt index 21840472cc..634fca7b36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -236,7 +236,7 @@ lxml==4.9.3 # via # mapentity # svglib -mapentity==8.10.0 +mapentity @ git+https://github.com/makinacorpus/django-mapentity.git@perf_delay_filters # via geotrek (setup.py) markdown==3.7 # via geotrek (setup.py) diff --git a/setup.py b/setup.py index b34032010c..1bf45ab75b 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def run(self): install_requires=[ 'Django==4.2.*', 'backports-zoneinfo;python_version<"3.10"', # not directly needed but required to make it worked with 3.10 - 'mapentity', + 'mapentity@git+https://github.com/makinacorpus/django-mapentity.git@perf_delay_filters#egg=mapentity', 'chardet', 'cairosvg', 'cairocffi',