diff --git a/geotrek/sensitivity/models.py b/geotrek/sensitivity/models.py index f322cb82ee..de1b83450c 100644 --- a/geotrek/sensitivity/models.py +++ b/geotrek/sensitivity/models.py @@ -251,20 +251,6 @@ def openair(self): } return wkt2openair(**data) - @property - def wgs84_geom(self): - geom = self.geom - if geom.geom_type == 'Point': - geom = geom.buffer(self.species.radius or settings.SENSITIVITY_DEFAULT_RADIUS, 4) - if self.species.radius: - geometry = () - for coords in geom.coords[0]: - coords += (self.species.radius, ) - geometry += (coords, ) - geom = GEOSGeometry(Polygon(geometry), srid=settings.SRID) - geom = geom.transform(4326, clone=True) # KML uses WGS84 - return geom - def is_public(self): return self.published diff --git a/geotrek/sensitivity/views.py b/geotrek/sensitivity/views.py index 58fc7c629b..70488e6869 100644 --- a/geotrek/sensitivity/views.py +++ b/geotrek/sensitivity/views.py @@ -211,7 +211,9 @@ class SensitiveAreaOpenAirList(PublicOrReadPermMixin, ListView): def get_queryset(self): aerial_practice = SportPractice.objects.filter(name__in=settings.SENSITIVITY_OPENAIR_SPORT_PRACTICES) - return SensitiveArea.objects.filter(species__practices__in=aerial_practice) + return SensitiveArea.objects.filter( + species__practices__in=aerial_practice, published=True + ).select_related('species') def render_to_response(self, context): areas = self.get_queryset() @@ -220,7 +222,13 @@ def render_to_response(self, context): * This file was created on: {timestamp}\n\n""".format(scheme=self.request.scheme, domain=self.request.META['HTTP_HOST'], timestamp=datetime.now()) airspace_list = [] for a in areas: - airspace_list.append(a.openair()) + if not a.openair(): + logger.error( + "The openair format cannot be generated for area %s-%s", + a.id, a + ) + else: + airspace_list.append(a.openair()) airspace_core = '\n\n'.join(airspace_list) airspace_file = file_header + airspace_core response = HttpResponse(airspace_file, content_type='application/octet-stream; charset=UTF-8')