|
@@ -2,6 +2,7 @@ from django.core.management.base import BaseCommand, CommandError
|
2
|
2
|
from django.conf import settings
|
3
|
3
|
from django.template.loader import render_to_string
|
4
|
4
|
from django.utils.html import strip_tags
|
|
5
|
+from django.utils import timezone
|
5
|
6
|
|
6
|
7
|
import subprocess
|
7
|
8
|
import re
|
|
@@ -211,15 +212,16 @@ class Command(BaseCommand):
|
211
|
212
|
|
212
|
213
|
if not notification:
|
213
|
214
|
# If this is the first notification, send it and make a database entry
|
214
|
|
- n = TLSNotification(queue_id=message["queue_id"], notification=datetime.datetime.today())
|
|
215
|
+ n = TLSNotification(queue_id=message["queue_id"], notification=timezone.now())
|
215
|
216
|
n.save()
|
216
|
217
|
send_mail(message, deleted=False)
|
217
|
218
|
else:
|
218
|
219
|
# If the last notification is more than 30 minutes ago,
|
219
|
220
|
# send another notification
|
220
|
|
- if notification.notification.replace(tzinfo=None) \
|
221
|
|
- < datetime.datetime.today() - datetime.timedelta(minutes=30):
|
|
221
|
+ if notification.notification \
|
|
222
|
+ < timezone.make_aware(datetime.datetime.now(), timezone.get_default_timezone()) \
|
|
223
|
+ - datetime.timedelta(minutes=30):
|
222
|
224
|
notification.delete()
|
223
|
|
- n = TLSNotification(queue_id=message["queue_id"], notification=datetime.datetime.today())
|
|
225
|
+ n = TLSNotification(queue_id=message["queue_id"], notification=timezone.now())
|
224
|
226
|
n.save()
|
225
|
|
- send_mail(message, deleted=False)
|
|
227
|
+ send_mail(message, deleted=False)
|