aboutsummaryrefslogtreecommitdiffstats
path: root/src/notifier
diff options
context:
space:
mode:
Diffstat (limited to 'src/notifier')
-rw-r--r--src/notifier/manager.py6
-rw-r--r--src/notifier/models.py7
-rw-r--r--src/notifier/tasks.py10
3 files changed, 11 insertions, 12 deletions
diff --git a/src/notifier/manager.py b/src/notifier/manager.py
index ee849a8..a5b7b9a 100644
--- a/src/notifier/manager.py
+++ b/src/notifier/manager.py
@@ -38,8 +38,8 @@ class NotificationHandler(object):
@classmethod
def booking_notify(cls, booking, template, titles):
"""
- Creates a notification for a booking owner and collaborators
- using the template.
+ Create a notification for a booking owner and collaborators using the template.
+
titles is a list - the first is the title for the owner's notification,
the last is the title for the collaborators'
"""
@@ -158,6 +158,8 @@ class NotificationHandler(object):
@classmethod
def task_updated(cls, task):
"""
+ Notification of task changing.
+
called every time a lab updated info about a task.
sends an email when 'task' changing state means a booking has
just been fulfilled (all tasks done, servers ready to use)
diff --git a/src/notifier/models.py b/src/notifier/models.py
index 382d3a9..0af748b 100644
--- a/src/notifier/models.py
+++ b/src/notifier/models.py
@@ -27,10 +27,8 @@ class Notification(models.Model):
class Emailed(models.Model):
- """
- A simple record to remember who has already gotten an email
- to avoid resending
- """
+ """A simple record to remember who has already gotten an email to avoid resending."""
+
begin_booking = models.OneToOneField(
Booking,
null=True,
@@ -49,4 +47,3 @@ class Emailed(models.Model):
on_delete=models.CASCADE,
related_name="over_mail"
)
-
diff --git a/src/notifier/tasks.py b/src/notifier/tasks.py
index b45ab8e..474d64d 100644
--- a/src/notifier/tasks.py
+++ b/src/notifier/tasks.py
@@ -19,15 +19,15 @@ from notifier.manager import NotificationHandler
@shared_task
def notify_expiring():
- """
- Notify users if their booking is within 48 hours of expiring.
- """
+ """Notify users if their booking is within 48 hours of expiring."""
expire_time = timezone.now() + timezone.timedelta(hours=settings.EXPIRE_HOURS)
# Don't email people about bookings that have started recently
start_time = timezone.now() - timezone.timedelta(hours=settings.EXPIRE_LIFETIME)
- bookings = Booking.objects.filter(end__lte=expire_time,
+ bookings = Booking.objects.filter(
+ end__lte=expire_time,
end__gte=timezone.now(),
- start__lte=start_time)
+ start__lte=start_time
+ )
for booking in bookings:
if Emailed.objects.filter(almost_end_booking=booking).exists():
continue