Skip to content

Commit

Permalink
make medium use a label as identifier
Browse files Browse the repository at this point in the history
this commit uses the backends label from NOTIFICATION_BACKENDS setting
for easier to rearrange backends
  • Loading branch information
sherzberg committed Aug 27, 2014
1 parent 6782099 commit b832c3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions notification/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ def load_backends():
)
# add the backend label and an instantiated backend class to the
# backends list.
backend_instance = getattr(mod, backend_class)(medium_id, spam_sensitivity)
backends.append(((medium_id, label), backend_instance))
backend_instance = getattr(mod, backend_class)(label, spam_sensitivity)
backends.append(((label, label), backend_instance))

return dict(backends)


Expand All @@ -49,5 +50,5 @@ def load_media_defaults(backends):
for key, backend in backends.items():
# key is a tuple (medium_id, backend_label)
media.append(key)
defaults[key[0]] = backend.spam_sensitivity
defaults[key[1]] = backend.spam_sensitivity
return media, defaults
2 changes: 1 addition & 1 deletion notification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class NoticeSetting(models.Model):

user = models.ForeignKey(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"))

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion notification/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
def get_backend_id(backend_name):
for bid, bname in NOTICE_MEDIA:
if bname == backend_name:
return bid
return bname
return None

0 comments on commit b832c3f

Please sign in to comment.