mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-03-16 21:30:24 +00:00
Fix #169
This commit is contained in:
parent
9f3e0105c2
commit
c31927aeff
2 changed files with 7 additions and 0 deletions
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue