Permalink
Browse files

Use medium_id more throughly and consistently.

  • Loading branch information...
1 parent 4d8b8ce commit 3c9d3ce10e54b02b68ebaf2bf89e0bd9e1ee2018 @brosner brosner committed Apr 19, 2009
Showing with 9 additions and 10 deletions.
  1. +3 −3 notification/backends/__init__.py
  2. +2 −2 notification/backends/base.py
  3. +1 −1 notification/backends/email.py
  4. +3 −4 notification/models.py
View
6 notification/backends/__init__.py
@@ -13,7 +13,7 @@
def load_backends():
backends = []
- for bits in getattr(settings, "NOTIFICATION_BACKENDS", default_backends):
+ for medium_id, bits in enumerate(getattr(settings, "NOTIFICATION_BACKENDS", default_backends)):
if len(bits) == 2:
label, backend_path = bits
spam_sensitivity = None
@@ -31,6 +31,6 @@ def load_backends():
raise exceptions.ImproperlyConfigured, 'Error importing notification backend %s: "%s"' % (backend_mod, e)
# add the backend label and an instantiated backend class to the
# backends list.
- backend_instance = getattr(mod, backend_class)(label, spam_sensitivity)
- backends.append((label, backend_instance))
+ backend_instance = getattr(mod, backend_class)(medium_id, spam_sensitivity)
+ backends.append((label, medium_id, backend_instance))
return dict(backends)
View
4 notification/backends/base.py
@@ -5,8 +5,8 @@ class BaseBackend(object):
"""
The base backend.
"""
- def __init__(self, label, spam_sensitivity=None):
- self.label = label
+ def __init__(self, medium_id, spam_sensitivity=None):
+ self.medium_id = medium_id
if spam_sensitivity is not None:
self.spam_sensitivity = spam_sensitivity
View
2 notification/backends/email.py
@@ -20,7 +20,7 @@ class EmailBackend(backends.BaseBackend):
def can_send(self, user, notice_type):
from notification.models import should_send
- if should_send(user, notice_type, self.label) and user.email:
+ if should_send(user, notice_type, self.medium_id) and user.email:
return True
return False
View
7 notification/models.py
@@ -52,10 +52,9 @@ class Meta:
NOTICE_MEDIA = []
NOTICE_MEDIA_DEFAULTS = {}
-for i, items in enumerate(NOTIFICATION_BACKENDS.items()):
- backend_label, backend = items
- NOTICE_MEDIA.append((i, backend_label))
- NOTICE_MEDIA_DEFAULTS[i] = backend.spam_sensitivity
+for backend_label, medium_id, backend in NOTIFICATION_BACKENDS:
+ NOTICE_MEDIA.append((medium_id, backend_label))
+ NOTICE_MEDIA_DEFAULTS[medium_id] = backend.spam_sensitivity
class NoticeSetting(models.Model):
"""

0 comments on commit 3c9d3ce

Please sign in to comment.