This commit is contained in:
Alvaro Leonel 2017-06-26 21:58:02 -04:00
parent eb22c8082e
commit c5f1579450
2 changed files with 5 additions and 2 deletions

View file

@ -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')

View file

@ -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: