diff --git a/manager/migrations/0039_auto_20190124_1023.py b/manager/migrations/0039_auto_20190124_1023.py new file mode 100644 index 0000000..e124924 --- /dev/null +++ b/manager/migrations/0039_auto_20190124_1023.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.5 on 2019-01-24 10:23 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('manager', '0038_auto_20190124_1022'), + ] + + operations = [ + migrations.AddField( + model_name='notification', + name='on_login', + field=models.BooleanField(default=False, verbose_name='Display Notification on Login Screen'), + ), + migrations.AlterField( + model_name='device', + name='wifi', + field=models.ManyToManyField(blank=True, to='manager.Wifi'), + ), + ] diff --git a/manager/templatetags/__init__.py b/manager/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/manager/templatetags/notifications.py b/manager/templatetags/notifications.py new file mode 100644 index 0000000..7067142 --- /dev/null +++ b/manager/templatetags/notifications.py @@ -0,0 +1,10 @@ +from django import template +from manager.models import Notification +from django.utils import timezone + +register = template.Library() + +@register.inclusion_tag('manager/notifications.html', takes_context=True) +def getNotifications(context): + return { 'notifications': Notification.objects.filter(expiry__gte = timezone.now()) } # TODO + diff --git a/templates/manager/notifications.html b/templates/manager/notifications.html new file mode 100644 index 0000000..46d67f7 --- /dev/null +++ b/templates/manager/notifications.html @@ -0,0 +1,5 @@ +{% for notification in notifications %} +
+ {% if notification.status == 0 %}Notice:{% elif notification.status == 1 %}Warning:{% else %}Emergency:{% endif %} {{ notification.text }} +
+{% endfor %}