From 057a311643093576f263b2530b771e36816897e1 Mon Sep 17 00:00:00 2001 From: Spencer Herzberg Date: Wed, 27 Aug 2014 10:29:53 -0600 Subject: [PATCH] make medium use a label as identifier this commit uses the backends label from NOTIFICATION_BACKENDS setting for easier to rearrange backends Conflicts: notification/backends/__init__.py pinax/notifications/models.py --- pinax/notifications/conf.py | 4 ++-- pinax/notifications/models.py | 2 +- pinax/notifications/tests/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pinax/notifications/conf.py b/pinax/notifications/conf.py index 66e1586b..825ac5be 100644 --- a/pinax/notifications/conf.py +++ b/pinax/notifications/conf.py @@ -65,8 +65,8 @@ def configure_backends(self, value): raise ImproperlyConfigured( "NOTIFICATION_BACKENDS does not contain enough data." ) - backend_instance = load_path_attr(backend_path)(medium_id, spam_sensitivity) - backends.append(((medium_id, label), backend_instance)) + backend_instance = load_path_attr(backend_path)(label, spam_sensitivity) + backends.append(((label, label), backend_instance)) return dict(backends) def configure_get_language_model(self, value): diff --git a/pinax/notifications/models.py b/pinax/notifications/models.py index ef8df463..a4c7a1ba 100644 --- a/pinax/notifications/models.py +++ b/pinax/notifications/models.py @@ -79,7 +79,7 @@ class NoticeSetting(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_("user")) notice_type = models.ForeignKey(NoticeType, verbose_name=_("notice type")) - medium = models.CharField(_("medium"), max_length=1, choices=NOTICE_MEDIA) + medium = models.CharField(_("medium"), max_length=100, choices=NOTICE_MEDIA) send = models.BooleanField(_("send"), default=False) scoping_content_type = models.ForeignKey(ContentType, null=True, blank=True) scoping_object_id = models.PositiveIntegerField(null=True, blank=True) diff --git a/pinax/notifications/tests/__init__.py b/pinax/notifications/tests/__init__.py index 125565a0..e0a4a1c0 100644 --- a/pinax/notifications/tests/__init__.py +++ b/pinax/notifications/tests/__init__.py @@ -2,5 +2,5 @@ def get_backend_id(backend_name): from ..models import NOTICE_MEDIA for bid, bname in NOTICE_MEDIA: if bname == backend_name: - return bid + return bname return None