Skip to content

Commit

Permalink
Merge branch 'develop' into r/feature/check_promo
Browse files Browse the repository at this point in the history
  • Loading branch information
ZUS666 authored Oct 31, 2023
2 parents 66aae8a + ea293fb commit de3c841
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions api_spot/api/views/add_spots.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from api.exceptions import AddSpotsError
from api.serializers import AddSpotsSerializer
from spots.models import Location, Spot, SpotEquipment
from spots.services import delete_location_cache_in_spot


@extend_schema(
Expand Down Expand Up @@ -56,6 +57,7 @@ def post(self, request, location_id, *args, **kwargs):
) for sp in new_spots for eq in equipments
]
SpotEquipment.objects.bulk_create(bulk2)
delete_location_cache_in_spot(location_id)
return Response(
{'count_created_spots': len(new_spots)},
status=status.HTTP_201_CREATED
Expand Down
3 changes: 3 additions & 0 deletions api_spot/spots/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

class SpotsConfig(AppConfig):
name = 'spots'

def ready(self) -> None:
from spots import siglnals # noqa: F401
4 changes: 0 additions & 4 deletions api_spot/spots/models/spot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,3 @@ def __str__(self):
def save(self, *args, **kwargs):
delete_location_cache_in_spot(self.location_id)
return super().save(*args, **kwargs)

def delete(self, *args, **kwargs):
delete_location_cache_in_spot(self.location_id)
return super().delete(*args, **kwargs)
10 changes: 10 additions & 0 deletions api_spot/spots/siglnals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db.models.signals import post_delete
from django.dispatch import receiver

from spots.models import Spot
from spots.services import delete_location_cache_in_spot


@receiver(post_delete, sender=Spot)
def delete_cache_spots_signal(sender, instance, *args, **kwargs):
delete_location_cache_in_spot(instance.location.id)

0 comments on commit de3c841

Please sign in to comment.