Browse files

Moved should_send function call to BaseBackend to reduce code duplica…

…tion.

This change is backwards incompatible in the sense that if should_send changes
you may be affected.
  • Loading branch information...
1 parent a48821f commit 9d2da7ffb4834ae88e27d72c19e0c20eb7c44256 @brosner brosner committed Apr 19, 2009
Showing with 5 additions and 2 deletions.
  1. +3 −0 notification/backends/base.py
  2. +2 −2 notification/backends/email.py
View
3 notification/backends/base.py
@@ -15,6 +15,9 @@ def can_send(self, user, notice_type):
Determines whether this backend is allowed to send a notification to
the given user and notice_type.
"""
+ from notification.models import should_send
+ if should_send(user, notice_type, self.medium_id):
+ return True
return False
def deliver(self, recipient, notice_type, extra_context):
View
4 notification/backends/email.py
@@ -20,8 +20,8 @@ class EmailBackend(backends.BaseBackend):
spam_sensitivity = 2
def can_send(self, user, notice_type):
- from notification.models import should_send
- if should_send(user, notice_type, self.medium_id) and user.email:
+ can_send = super(EmailBackend, self).can_send(user, notice_type)
+ if can_send and user.email:
return True
return False

0 comments on commit 9d2da7f

Please sign in to comment.