[V1.0] Working application, added notifications.

Ready to upload to store.
This commit is contained in:
c-d-p
2025-04-27 00:39:52 +02:00
parent 04d9136b96
commit 62d6b8bdfd
86 changed files with 2250 additions and 240 deletions

View File

@@ -7,7 +7,13 @@ from core.exceptions import not_found_exception
from modules.calendar.schemas import (
CalendarEventCreate,
CalendarEventUpdate,
) # Import schemas
)
# Import the celery app instance instead of the task functions directly
from core.celery_app import celery_app
# Keep task imports if cancel_event_notifications is still called directly and synchronously
from modules.calendar.tasks import cancel_event_notifications
def create_calendar_event(db: Session, user_id: int, event_data: CalendarEventCreate):
@@ -23,6 +29,11 @@ def create_calendar_event(db: Session, user_id: int, event_data: CalendarEventCr
db.add(event)
db.commit()
db.refresh(event)
# Schedule notifications using send_task
celery_app.send_task(
"modules.calendar.tasks.schedule_event_notifications", # Task name as string
args=[event.id],
)
return event
@@ -114,10 +125,17 @@ def update_calendar_event(
db.commit()
db.refresh(event)
# Re-schedule notifications using send_task
celery_app.send_task(
"modules.calendar.tasks.schedule_event_notifications", args=[event.id]
)
return event
def delete_calendar_event(db: Session, user_id: int, event_id: int):
event = get_calendar_event_by_id(db, user_id, event_id) # Reuse get_by_id for check
# Cancel any scheduled notifications before deleting
# Run synchronously here or make cancel_event_notifications an async task
cancel_event_notifications(event_id)
db.delete(event)
db.commit()