diff --git a/notifications/tests/tests.py b/notifications/tests/tests.py index 94d1135..6d56603 100644 --- a/notifications/tests/tests.py +++ b/notifications/tests/tests.py @@ -319,6 +319,7 @@ class NotificationTestPages(TestCase): self.assertEqual(data['unread_count'], 1) self.assertEqual(len(data['unread_list']), 1) self.assertEqual(data['unread_list'][0]['verb'], 'commented') + self.assertEqual(data['unread_list'][0]['slug'], id2slug(data['unread_list'][0]['id'])) def test_unread_list_api_mark_as_read(self): self.login('to', 'pwd') diff --git a/notifications/views.py b/notifications/views.py index 0958659..a60747d 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -1,3 +1,5 @@ +from distutils.version import StrictVersion + from django import get_version from django.conf import settings from django.contrib.auth.decorators import login_required @@ -6,10 +8,9 @@ from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator from django.views.generic import ListView -from .utils import slug2id from .models import Notification +from .utils import id2slug, slug2id -from distutils.version import StrictVersion if StrictVersion(get_version()) >= StrictVersion('1.7.0'): from django.http import JsonResponse else: @@ -149,6 +150,7 @@ def live_unread_notification_list(request): for n in request.user.notifications.unread()[0:num_to_fetch]: struct = model_to_dict(n) + struct['slug'] = id2slug(n.id) if n.actor: struct['actor'] = str(n.actor) if n.target: