diff --git a/sigi/apps/espacos/apps.py b/sigi/apps/espacos/apps.py index 0dab50c..15da7f9 100644 --- a/sigi/apps/espacos/apps.py +++ b/sigi/apps/espacos/apps.py @@ -7,8 +7,3 @@ class EspacosConfig(AppConfig): name = "espacos" name = "sigi.apps.espacos" verbose_name = _("Agenda de espaços") - - def ready(self): - from . import signals - - return super().ready() diff --git a/sigi/apps/espacos/signals.py b/sigi/apps/espacos/signals.py deleted file mode 100644 index af52cc1..0000000 --- a/sigi/apps/espacos/signals.py +++ /dev/null @@ -1,22 +0,0 @@ -import traceback -from django.conf import settings -from django.core.mail import send_mail -from django.db.models.signals import pre_delete -from django.dispatch import receiver -from django.utils import timezone -from sigi.apps.espacos.models import Reserva - - -@receiver(pre_delete, sender=Reserva) -def reserva_pre_delete(sender, **kwargs): - origin = kwargs.get("origin", None) - if origin and origin.count() == Reserva.objects.count(): - stack_array = [f"At {timezone.localtime()} all records deleted:"] - stack_array.extend(traceback.format_stack()) - send_mail( - subject="Armadilha deleção de reservas", - message="\n".join(stack_array), - from_email=settings.DEFAULT_FROM_EMAIL, - recipient_list=[email for name, email in settings.ADMINS], - fail_silently=True, - ) diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 0a30821..c27e777 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -698,13 +698,13 @@ class Evento(models.Model): self.turma = f"{proximo:02}/{ano:04}" # É preciso salvar para poder usar o relacionamento com convites + super().save(*args, **kwargs) if self.reserva is None: reservas_remover = list(Reserva.objects.filter(evento=self)) else: self.update_reserva() self.reserva.save() reservas_remover = Reserva.objects.none() - super().save(*args, **kwargs) for reserva in reservas_remover: reserva.delete()