From a733ad2b3530878680b3272ffd8ef2ee9a0e2f82 Mon Sep 17 00:00:00 2001 From: Jonas Svensson Date: Thu, 9 Aug 2012 00:47:28 +0200 Subject: [PATCH] Empty guestbooks dont crash --- apps/accounts/views.py | 1 + apps/core/static/js/frontpage.js | 1 - apps/notifications/templatetags/notification_tags.py | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/accounts/views.py b/apps/accounts/views.py index 9ece147..19ec12b 100644 --- a/apps/accounts/views.py +++ b/apps/accounts/views.py @@ -9,6 +9,7 @@ from django.contrib.auth.forms import PasswordChangeForm from django.contrib import messages from django.contrib.humanize.templatetags.humanize import naturalday +from django.http import Http404 from apps.core.utils import render, get_datatables_records diff --git a/apps/core/static/js/frontpage.js b/apps/core/static/js/frontpage.js index 61e8817..561d864 100644 --- a/apps/core/static/js/frontpage.js +++ b/apps/core/static/js/frontpage.js @@ -200,5 +200,4 @@ jQuery(document).ready(function() { return false; }); - }); \ No newline at end of file diff --git a/apps/notifications/templatetags/notification_tags.py b/apps/notifications/templatetags/notification_tags.py index 81d101f..2d7625a 100644 --- a/apps/notifications/templatetags/notification_tags.py +++ b/apps/notifications/templatetags/notification_tags.py @@ -46,9 +46,10 @@ def get_notes_for_articlelist(context, queryset, user): @register.assignment_tag(takes_context=True) def get_notes_for_guestbook(context, queryset, user): - notifications = _get_notifications_for_qs(queryset, user) - queryset = _assign_notifications_on_qs(queryset, notifications) - new_notifications = _set_status_on_qs(notifications, 3) + if len(queryset) > 0: + notifications = _get_notifications_for_qs(queryset, user) + queryset = _assign_notifications_on_qs(queryset, notifications) + new_notifications = _set_status_on_qs(notifications, 3) return queryset