From: Patrick Samson Date: Mon, 4 Feb 2013 20:17:46 +0000 (+0100) Subject: Support of django-notification extended from version 0.2.0 to 1.0. X-Git-Tag: 3.0.0~8 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=81862bd55acf77831f627d463344ef9f5501bfbf;p=django-postman.git Support of django-notification extended from version 0.2.0 to 1.0. --- diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 300cc75..62666c8 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -114,6 +114,8 @@ You may specify some additional configuration options in your :file:`settings.py *Defaults to*: 'notification', as in django-notification. + 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. + If you already have a notifier application with the default name in the installed applications but you do not want it to be used by this application, set the option to None. diff --git a/postman/management/__init__.py b/postman/management/__init__.py index 45a96bc..201eb20 100644 --- a/postman/management/__init__.py +++ b/postman/management/__init__.py @@ -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) diff --git a/postman/tests.py b/postman/tests.py index 0ed24af..7d49de6 100644 --- a/postman/tests.py +++ b/postman/tests.py @@ -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."