diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2019-12-19 12:39:01 -0500 |
---|---|---|
committer | Parker Berberian <pberberian@iol.unh.edu> | 2020-01-28 16:09:35 -0500 |
commit | 77377d5e9362bd35a3b300df231e82ee974675e1 (patch) | |
tree | 5e3799768eb887a0259c8c21ed61123cdde2d608 /src/notifier | |
parent | 899e1a4baa95d0bc6f0eef34de66f0e257174878 (diff) |
Comments and Documentation
This change adds a ton of comments and documentation across all the code.
Change-Id: Ifee0a2f534e8584f14b0f13af4dda8dc70eb7553
Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/notifier')
-rw-r--r-- | src/notifier/manager.py | 6 | ||||
-rw-r--r-- | src/notifier/models.py | 7 | ||||
-rw-r--r-- | src/notifier/tasks.py | 10 |
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 |