]> git.parisson.com Git - django-postman.git/commitdiff
Support of django-notification extended from version 0.2.0 to 1.0.
authorPatrick Samson <pk.samson@gmail.com>
Mon, 4 Feb 2013 20:17:46 +0000 (21:17 +0100)
committerPatrick Samson <pk.samson@gmail.com>
Mon, 4 Feb 2013 20:17:46 +0000 (21:17 +0100)
docs/quickstart.rst
postman/management/__init__.py
postman/tests.py

index 300cc753acf20bbb1cf4fce610795abb15b7c26b..62666c8a6c32d3e7de6abb6a9e430b4ca93cc6f7 100644 (file)
@@ -114,6 +114,8 @@ You may specify some additional configuration options in your :file:`settings.py
 \r
     *Defaults to*: 'notification', as in django-notification.\r
 \r
+    Note: django-notification v0.2.0 works with Django version 1.3. As of Django 1.4, switch to at least django-notification v1.0.\r
+\r
     If you already have a notifier application with the default name in the installed applications\r
     but you do not want it to be used by this application, set the option to None.\r
 \r
index 45a96bc6f813b488bc0ce3763ad477ce99b9234a..201eb20665b28183667b7e3ee12e6698da008f30 100644 (file)
@@ -10,11 +10,15 @@ if name and name in settings.INSTALLED_APPS:
     name = name + '.models'
     __import__(name)
     notification = sys.modules[name]
+    try:
+        create = notification.NoticeType.create  # django-notification 1.0
+    except AttributeError:
+        create = notification.create_notice_type  # django-notification 0.2.0 (works only with DJ <= 1.3)
 
     def create_notice_types(*args, **kwargs):
-        notification.create_notice_type("postman_rejection", _("Message Rejected"), _("Your message has been rejected"))
-        notification.create_notice_type("postman_message", _("Message Received"), _("You have received a message"))
-        notification.create_notice_type("postman_reply", _("Reply Received"), _("You have received a reply"))
+        create("postman_rejection", _("Message Rejected"), _("Your message has been rejected"))
+        create("postman_message", _("Message Received"), _("You have received a message"))
+        create("postman_reply", _("Reply Received"), _("You have received a reply"))
 
     signals.post_syncdb.connect(create_notice_types, sender=notification)
 
index 0ed24af943845b5fabd11bf42e431779bdad565e..7d49de649c34edee42c9f4200e6a80d37cadb901 100644 (file)
@@ -1301,8 +1301,9 @@ class MessageTest(BaseTest):
             self.assertEqual(mail.outbox[0].to, [email])
         from postman.utils import notification
         if notification and notice_label:
-            notice = notification.Notice.objects.get()
-            self.assertEqual(notice.notice_type.label, notice_label)
+            if hasattr(notification, "Notice"):  # exists for django-notification 0.2.0, but no more in 1.0
+                notice = notification.Notice.objects.get()
+                self.assertEqual(notice.notice_type.label, notice_label)
 
     def test_notification_rejection_visitor(self):
         "Test notify_users() for rejection, sender is a visitor."