Skip to content

Commit

Permalink
Do not check for limits at all if there is no area limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov authored and lanseg committed Dec 24, 2024
1 parent acf0dd3 commit ad83419
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])],
Expand All @@ -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,
Expand Down

0 comments on commit ad83419

Please sign in to comment.