From 267bf2b999d18e5cbb35aa99ca1f711a1536cec3 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Date: Thu, 24 Jan 2019 18:35:23 +0100 Subject: [PATCH] Add login screen-only notifications --- manager/templatetags/notifications.py | 5 +++-- templates/two_factor/core/login.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manager/templatetags/notifications.py b/manager/templatetags/notifications.py index d537d9e..753c5f2 100644 --- a/manager/templatetags/notifications.py +++ b/manager/templatetags/notifications.py @@ -1,10 +1,11 @@ from django import template from manager.models import Notification from django.utils import timezone +from django.db.models import Q register = template.Library() @register.inclusion_tag('manager/notifications.html', takes_context=True) -def getNotifications(context): - return { 'notifications': Notification.objects.filter(expiry__gte = timezone.now()), 'context': context } # TODO +def getNotifications(context, login=False): + return { 'notifications': [notification for notification in Notification.objects.filter(Q(expiry__gte = timezone.now()) | Q(expiry = None)) if (notification.on_login or (not login)) ] } diff --git a/templates/two_factor/core/login.html b/templates/two_factor/core/login.html index f49269f..4707e73 100644 --- a/templates/two_factor/core/login.html +++ b/templates/two_factor/core/login.html @@ -18,7 +18,7 @@ -{% getNotifications %} +{% getNotifications True %} {% if wizard.steps.current == 'auth' %} {% if user.is_authenticated %}