From 77377d5e9362bd35a3b300df231e82ee974675e1 Mon Sep 17 00:00:00 2001 From: Parker Berberian Date: Thu, 19 Dec 2019 12:39:01 -0500 Subject: Comments and Documentation This change adds a ton of comments and documentation across all the code. Change-Id: Ifee0a2f534e8584f14b0f13af4dda8dc70eb7553 Signed-off-by: Parker Berberian --- src/notifier/manager.py | 6 ++++-- src/notifier/models.py | 7 ++----- src/notifier/tasks.py | 10 +++++----- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src/notifier') 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 -- cgit 1.2.3-korg