From c31927aeff94e75fbfe643df011162b6a4ad7fe4 Mon Sep 17 00:00:00 2001 From: Alvaro Leonel Date: Thu, 1 Jun 2017 23:12:33 -0400 Subject: [PATCH] Fix #169 --- notifications/models.py | 3 +++ notifications/tests/tests.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/notifications/models.py b/notifications/models.py index 0376b8d..62080f6 100644 --- a/notifications/models.py +++ b/notifications/models.py @@ -11,6 +11,7 @@ else: from django.contrib.contenttypes.generic import GenericForeignKey from django.db import models +from django.db.models.query import QuerySet from django.core.exceptions import ImproperlyConfigured from django.utils.six import text_type from .utils import id2slug @@ -251,6 +252,8 @@ def notify_handler(verb, **kwargs): # Check if User or Group if isinstance(recipient, Group): recipients = recipient.user_set.all() + elif isinstance(recipient, QuerySet) or isinstance(recipient, list): + pass else: recipients = [recipient] diff --git a/notifications/tests/tests.py b/notifications/tests/tests.py index 99ccf9a..9ebdf97 100644 --- a/notifications/tests/tests.py +++ b/notifications/tests/tests.py @@ -58,12 +58,16 @@ class NotificationManagersTest(TestCase): self.from_user = User.objects.create(username="from2", password="pwd", email="example@example.com") self.to_user = User.objects.create(username="to2", password="pwd", email="example@example.com") self.to_group = Group.objects.create(name="to2_g") + self.to_user_list = User.objects.all() self.to_group.user_set.add(self.to_user) for i in range(self.message_count): notify.send(self.from_user, recipient=self.to_user, verb='commented', action_object=self.from_user) # Send notification to group notify.send(self.from_user, recipient=self.to_group, verb='commented', action_object=self.from_user) self.message_count += 1 + # Send notification to user list + notify.send(self.from_user, recipient=self.to_user_list, verb='commented', action_object=self.from_user) + self.message_count += 1 def test_unread_manager(self): self.assertEqual(Notification.objects.unread().count(), self.message_count)