From 529df2d0ab8dee46fe8ecee43dd038896b6a23cf Mon Sep 17 00:00:00 2001 From: timofejmalinin Date: Mon, 17 Apr 2023 20:00:12 +0400 Subject: [PATCH] raschet restrictions edit --- service/service.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service/service.py b/service/service.py index 49d9da2..47628cf 100644 --- a/service/service.py +++ b/service/service.py @@ -22,6 +22,7 @@ class PointService: @staticmethod def update_points_in_radius(qs: models.PlacementPoint, new_status: str): + triggers = False for point in qs: if new_status == PointStatus.Installation.name: if point.status == PointStatus.Pending.name: @@ -29,16 +30,18 @@ class PointService: geometry__distance_lt=(point.geometry, Distance(m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS)), ) pnts.update(prediction_first=F('prediction_current'), target_post_cnt=F('target_post_cnt') + 1) - raschet.delay() + triggers = True elif new_status == PointStatus.Cancelled.name or new_status == PointStatus.Pending.name: if point.status == PointStatus.Installation.name: pnts = models.PlacementPoint.objects.filter( geometry__distance_lt=(point.geometry, Distance(m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS)), ) pnts.update(target_post_cnt=F('target_post_cnt') - 1 if F('target_post_cnt') != 0 else 0) - raschet.delay() + triggers = True elif new_status == PointStatus.Working.name and point.status == PointStatus.Pending.name: - raschet.delay() + triggers = True + if triggers: + raschet.delay() @staticmethod def update_status(qs: models.PlacementPoint, new_status: str) -> models.PlacementPoint: