1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from celery import shared_task
12 from datetime import timedelta
14 from django.conf import settings
15 from django.utils import timezone
17 from notification.models import BookingNotification
18 from notification_framework.notification import Notification
22 def send_booking_notifications():
23 messaging = Notification(dashboard_url=settings.RABBITMQ_URL)
26 notifications = BookingNotification.objects.filter(submitted=False,
28 submit_time__lt=now + timedelta(minutes=5))
29 for notification in notifications:
30 messaging.send(notification.type, notification.booking.resource.name,
31 notification.get_content())
32 notification.submitted = True