|
|
|
|
@ -7,6 +7,7 @@ from django.db.models import F
|
|
|
|
|
from postamates.settings import DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS
|
|
|
|
|
from service import models
|
|
|
|
|
from service.enums import PointStatus
|
|
|
|
|
from service.tasks import raschet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PointService:
|
|
|
|
|
@ -27,12 +28,14 @@ class PointService:
|
|
|
|
|
geometry__distance_lt=(point.geometry, Distance(m=DEFAULT_PLACEMENT_POINT_UPDATE_RADIUS)),
|
|
|
|
|
)
|
|
|
|
|
pnts.update(target_post_cnt=F('target_post_cnt') + 1)
|
|
|
|
|
raschet.delay()
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def update_status(qs: models.PlacementPoint, new_status: str) -> models.PlacementPoint:
|
|
|
|
|
|