|
|
@ -1,5 +1,5 @@
|
|
|
|
from celery import shared_task
|
|
|
|
from celery import shared_task
|
|
|
|
from .models import Message
|
|
|
|
from .models import Message, ShiftRegistration
|
|
|
|
from django.db import transaction
|
|
|
|
from django.db import transaction
|
|
|
|
from django.utils import timezone
|
|
|
|
from django.utils import timezone
|
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
|
|
|
from dynamic_preferences.registries import global_preferences_registry
|
|
|
@ -36,3 +36,14 @@ def send_message(msgid):
|
|
|
|
print(f"TODO: send message @{msg.to.phone} {msg.text}")
|
|
|
|
print(f"TODO: send message @{msg.to.phone} {msg.text}")
|
|
|
|
msg.sent_at = timezone.now()
|
|
|
|
msg.sent_at = timezone.now()
|
|
|
|
msg.save()
|
|
|
|
msg.save()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shared_task
|
|
|
|
|
|
|
|
def send_reminders():
|
|
|
|
|
|
|
|
with transaction.atomic():
|
|
|
|
|
|
|
|
for reg in ShiftRegistration.objects.select_for_update().filter(
|
|
|
|
|
|
|
|
reminder_sent=False,
|
|
|
|
|
|
|
|
shift__start_at__lte=timezone.now()
|
|
|
|
|
|
|
|
+ global_preferences["helper__reminder_time"],
|
|
|
|
|
|
|
|
):
|
|
|
|
|
|
|
|
reg.send_reminder()
|
|
|
|