Commits

Patrick Samson committed e05947f

adjustments for django 1.4

  • Participants
  • Parent commits b27889e

Comments (0)

Files changed (3)

File postman/management/commands/postman_cleanup.py

-import datetime
+from datetime import timedelta
 from optparse import make_option
 
 from django.core.management.base import NoArgsCommand
 from django.db.models import Max, Count, F, Q
+try:
+    from django.utils.timezone import now   # Django 1.4 aware datetimes
+except ImportError:
+    from datetime import datetime
+    now = datetime.now
 
 from postman.models import Message
 
     def handle_noargs(self, **options):
         verbose = int(options.get('verbosity'))
         days = options.get('days')
-        date = datetime.date.today() - datetime.timedelta(days=days)
+        date = now() - timedelta(days=days)
         if verbose >= 1:
             self.stdout.write("Erase messages and conversations marked as deleted before %s\n" % date)
         # for a conversation to be candidate, all messages must satisfy the criteria

File postman/test_urls.py

 
 """
 from django.conf import settings
-from django.conf.urls.defaults import *
+try:
+    from django.conf.urls import patterns, include, url # django 1.4
+except ImportError:
+    from django.conf.urls.defaults import patterns, include, url # django 1.3
 from django.forms import ValidationError
 from django.views.generic.simple import redirect_to
 

File postman/urls.py

     ..., {'formatters': (format_subject,format_body)}, name='postman_view'),
 
 """
-from django.conf.urls.defaults import *
+try:
+    from django.conf.urls import patterns, include, url # django 1.4
+except ImportError:
+    from django.conf.urls.defaults import patterns, include, url # django 1.3
 from django.views.generic.simple import redirect_to
 
 OPTION_MESSAGES = 'm'