|
|
@@ -1,4 +1,4 @@
|
|
|
-from datetime import timedelta
|
|
|
+from datetime import timedelta, datetime
|
|
|
from uuid import UUID
|
|
|
|
|
|
from fastapi import APIRouter, Depends, HTTPException
|
|
|
@@ -192,6 +192,7 @@ async def create_sms_batch(
|
|
|
# Get all slots
|
|
|
slots = session.execute(select(Slot).where(Slot.project_id == project_id))
|
|
|
sms_list = []
|
|
|
+ now = datetime.now()
|
|
|
for slot in slots.scalars():
|
|
|
# Replace the slot placeholder by their value
|
|
|
slot_content = (
|
|
|
@@ -202,6 +203,9 @@ async def create_sms_batch(
|
|
|
.replace("{respo}", slot.responsible_contact)
|
|
|
)
|
|
|
sending_time = slot.starting_time - timedelta(minutes=sms_batch.delta_t)
|
|
|
+ # Skip SMS that should have been send before now
|
|
|
+ if sending_time < now:
|
|
|
+ continue
|
|
|
for volunteer in slot.volunteers:
|
|
|
if not volunteer.automatic_sms:
|
|
|
continue
|