Skip to content

Commit

Permalink
Minor cleanup and update history file
Browse files Browse the repository at this point in the history
rubickcz committed Dec 11, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0412fac commit 1bad310
Showing 6 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -2,6 +2,12 @@
History
=======

0.4.2 (2020-12-11)
------------------

* Add ``send_push`` flag to ``AdminNotificationTemplate`` model
* Ignore duplicit dispatcher classes in ``BaseHandler``

0.4.1 (2020-10-12)
------------------

3 changes: 2 additions & 1 deletion example/tests/test_handlers.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ def dispatch(self, notification):

class TestDataHandler(BaseHandler):

dispatcher_classes = (MockDispatcher,)
# two identical dispatcher classes are intentional, duplicates must be ignored
dispatcher_classes = (MockDispatcher, MockDispatcher)

def get_recipients(self):
return self.signal_kwargs['recipients']
8 changes: 3 additions & 5 deletions pynotify/handlers.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ class BaseHandler(metaclass=HandlerMeta):
template_slug: Slug of an existing admin template to be used. If not defined, you must define
``get_template_data()`` method.
"""
dispatcher_classes = []
dispatcher_classes = ()
template_slug = None

@cached_property
@@ -83,10 +83,8 @@ def _template(self):

def _init_dispatchers(self):
self.dispatchers = []
dispatcher_classes = self.get_dispatcher_classes()
if dispatcher_classes:
for dispatcher_class in dispatcher_classes:
self.dispatchers.append(self._init_dispatcher(dispatcher_class))
for dispatcher_class in set(self.get_dispatcher_classes()):
self.dispatchers.append(self._init_dispatcher(dispatcher_class))

def _init_dispatcher(self, dispatcher_class):
return dispatcher_class()
2 changes: 0 additions & 2 deletions pynotify/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -44,8 +44,6 @@ msgid "is active"
msgstr "je aktivní"

#: models.py:63
#, fuzzy
#| msgid "notification"
msgid "send push notification"
msgstr "odesílat push notifikaci"

2 changes: 1 addition & 1 deletion pynotify/models.py
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ class AdminNotificationTemplate(BaseTemplate):
slug: Template slug, with which this template can be referred to.
is_active: Flag that switches on/off creating notifications from this template.
send_push: Flag that switches on/off sending push notifications from this template.
Currently, it has no effect on its own, but you can use it in your custom push notification solution.
Currently, it has no effect on its own, but you can use it in your custom push notification solution.
"""
slug = models.SlugField(max_length=200, unique=True, verbose_name=_l('slug'))
is_active = models.BooleanField(default=True, verbose_name=_l('is active'))
2 changes: 1 addition & 1 deletion pynotify/notify.py
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ def get_template_slug(self):
return self.signal_kwargs['template_slug']

def get_dispatcher_classes(self):
return self.signal_kwargs['dispatcher_classes']
return self.signal_kwargs['dispatcher_classes'] or ()

class Meta:
signal = notify_signal

0 comments on commit 1bad310

Please sign in to comment.