Patrick Samson avatar Patrick Samson committed e05947f

adjustments for django 1.4

Comments (0)

Files changed (3)

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

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
 
     ..., {'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'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.