From: Patrick Samson Date: Sun, 22 Apr 2012 08:30:33 +0000 (+0200) Subject: adjustments for django 1.4 X-Git-Tag: 2.0.0~12 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=dc463a2962598dd4ef528ef0029724c72ae62a6e;p=django-postman.git adjustments for django 1.4 --- diff --git a/postman/management/commands/postman_cleanup.py b/postman/management/commands/postman_cleanup.py index 194239c..509d8a7 100644 --- a/postman/management/commands/postman_cleanup.py +++ b/postman/management/commands/postman_cleanup.py @@ -1,8 +1,13 @@ -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 @@ -19,7 +24,7 @@ class Command(NoArgsCommand): 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 diff --git a/postman/test_urls.py b/postman/test_urls.py index 1812aa0..611014c 100644 --- a/postman/test_urls.py +++ b/postman/test_urls.py @@ -3,7 +3,10 @@ URLconf for tests.py usage. """ 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 diff --git a/postman/urls.py b/postman/urls.py index cd6495e..49d44c9 100644 --- a/postman/urls.py +++ b/postman/urls.py @@ -86,7 +86,10 @@ Refer to documentation. ..., {'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'