# HG changeset patch
# User durandn
# Date 1470673467 -7200
# Node ID 327f6719674e834e11eb321cb21c73761f9ef7fc
# Parent c6f82f959f77eae26874e3fa373fd64014a9e881
Pagination for notifications and changing notification badge color (yellow) to match new comment highlight color
diff -r c6f82f959f77 -r 327f6719674e src/iconolab/templates/iconolab/user_home.html
--- a/src/iconolab/templates/iconolab/user_home.html Mon Aug 08 16:30:12 2016 +0200
+++ b/src/iconolab/templates/iconolab/user_home.html Mon Aug 08 18:24:27 2016 +0200
@@ -16,13 +16,13 @@
{% if profile_user == request.user %}
{% notifications_unread as unread_count %}
-
{{unread_count}} Notifications non lues
+
- {% if notifications %}
+ {% if unread_count %}
+
+ {% if notifications.has_previous or notifications.has_next %}
+
+ {% endif %}
{% endif %}
diff -r c6f82f959f77 -r 327f6719674e src/iconolab/views/iconolab.py
--- a/src/iconolab/views/iconolab.py Mon Aug 08 16:30:12 2016 +0200
+++ b/src/iconolab/views/iconolab.py Mon Aug 08 18:24:27 2016 +0200
@@ -64,8 +64,15 @@
context = {}
notifications = Notification.objects.filter(recipient=request.user)
context["notifications_unread_ids"] = notifications.unread().values_list("id", flat=True)
- notifications.mark_all_as_read()
- context["notifications"] = notifications
+ page = request.GET.get("page", 1)
+ paginator = Paginator(notifications, 50)
+ try:
+ notifications_list = paginator.page(page)
+ except PageNotAnInteger:
+ notifications_list = paginator.page(1)
+ except EmptyPage:
+ notifications_list = paginator.page(paginator.num_pages)
+ context["notifications"] = notifications_list
return render(request, 'iconolab/user_notifications.html', context)