Add login screen-only notifications

This commit is contained in:
Kumi 2019-01-24 18:35:23 +01:00
parent a0b82c3c97
commit 267bf2b999
2 changed files with 4 additions and 3 deletions

View file

@ -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)) ] }

View file

@ -18,7 +18,7 @@
</div>
</noscript>
{% getNotifications %}
{% getNotifications True %}
{% if wizard.steps.current == 'auth' %}
{% if user.is_authenticated %}