Browse Source

fixed timezone issue

Hendrik Sünkler 8 years ago
parent
commit
b95a9e9d18
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      posttls/core/management/commands/process_queue.py

+ 7
- 5
posttls/core/management/commands/process_queue.py View File

2
 from django.conf import settings
2
 from django.conf import settings
3
 from django.template.loader import render_to_string
3
 from django.template.loader import render_to_string
4
 from django.utils.html import strip_tags
4
 from django.utils.html import strip_tags
5
+from django.utils import timezone
5
 
6
 
6
 import subprocess
7
 import subprocess
7
 import re
8
 import re
211
 
212
 
212
                     if not notification:
213
                     if not notification:
213
                         # If this is the first notification, send it and make a database entry
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
                         n.save()
216
                         n.save()
216
                         send_mail(message, deleted=False)
217
                         send_mail(message, deleted=False)
217
                     else:
218
                     else:
218
                         # If the last notification is more than 30 minutes ago,
219
                         # If the last notification is more than 30 minutes ago,
219
                         # send another notification
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
                             notification.delete()
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
                             n.save()
226
                             n.save()
225
-                            send_mail(message, deleted=False)
227
+                            send_mail(message, deleted=False)

Loading…
Cancel
Save