From 10e2e9ad7e5c96c7b631e53e74b15d8da23b1353 Mon Sep 17 00:00:00 2001 From: Andrey Rusakov Date: Fri, 20 Dec 2024 16:19:40 +0100 Subject: [PATCH] Do not check for limits at all if there is no area limit --- api/serializers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index cc01c8b..02f77ed 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -297,7 +297,7 @@ class OrderSerializer(serializers.ModelSerializer): def validate(self, attrs): super().validate(attrs) self._errors = {} - if 'geom' not in attrs: + if ('geom' not in attrs) or (settings.MAX_ORDER_AREA == 0): return attrs requestedGeom = Polygon( [xy[0:2] for xy in list(attrs['geom'].coords[0])], @@ -314,8 +314,8 @@ def validate(self, attrs): ownedRequestedGeom = requestedGeom.intersection(ownedAreas) attrs['actualGeom'] = ownedRequestedGeom - if (round(ownedRequestedGeom.area) == 0 and settings.MAX_ORDER_AREA > 0 - and requestedGeom.area > settings.MAX_ORDER_AREA): + if (round(ownedRequestedGeom.area) == 0 and + requestedGeom.area > settings.MAX_ORDER_AREA): raise ValidationError({ 'message': _(f'Order area is too large'), 'expected': settings.MAX_ORDER_AREA,