latest changes before manual submissions redesign

This commit is contained in:
Joren de Graaf
2026-10-06 19:31:30 +02:00
parent 46ad514a70
commit c13a405d96
124 changed files with 1023 additions and 112 deletions
+19
View File
@@ -0,0 +1,19 @@
from django.db.models import F
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from members.models import PendingNotificationBatch, UserSettings
from .models import PendingEvent
@receiver(post_save, sender=PendingEvent)
def count_new_pending_event(sender, instance, created, **kwargs):
if not created:
return
minute = timezone.now().replace(second=0, microsecond=0)
field = "manual_count" if instance.source_type == PendingEvent.SourceType.MANUAL else "sensor_count"
for user_id in UserSettings.objects.filter(ntfy_enabled=True).exclude(ntfy_url="").values_list("user_id", flat=True):
batch, _ = PendingNotificationBatch.objects.get_or_create(user_id=user_id, minute=minute)
PendingNotificationBatch.objects.filter(pk=batch.pk).update(**{field: F(field) + 1})