Implement notifications - login filtering not working yet!
This commit is contained in:
parent
4391326072
commit
f55ab7efef
7 changed files with 55 additions and 3 deletions
|
@ -1,11 +1,12 @@
|
|||
from django.contrib import admin
|
||||
from .models import Organization, Device, Network, Model, Wifi
|
||||
from .models import Organization, Device, Network, Model, Wifi, Notification
|
||||
|
||||
admin.site.register(Organization)
|
||||
admin.site.register(Device)
|
||||
admin.site.register(Network)
|
||||
admin.site.register(Model)
|
||||
admin.site.register(Wifi)
|
||||
admin.site.register(Notification)
|
||||
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
|
|
27
manager/migrations/0038_auto_20190124_1022.py
Normal file
27
manager/migrations/0038_auto_20190124_1022.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Generated by Django 2.1.5 on 2019-01-24 10:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('manager', '0037_auto_20190119_0912'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Notification',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('status', models.IntegerField(choices=[(0, 'NOTICE'), (1, 'ALERT'), (2, 'EMERGENCY')], verbose_name='Status')),
|
||||
('text', models.CharField(max_length=1024, verbose_name='Notification Text')),
|
||||
('expiry', models.DateTimeField(blank=True, null=True, verbose_name='Notification Expiry')),
|
||||
],
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='device',
|
||||
name='wifi',
|
||||
field=models.ManyToManyField(blank=True, to='manager.Wifi'),
|
||||
),
|
||||
]
|
|
@ -147,3 +147,18 @@ class WifiLog(models.Model):
|
|||
oldvalue = models.CharField("Old Value", max_length=256, blank=True, null=True)
|
||||
newvalue = models.CharField("New Value", max_length=256, blank=True, null=True)
|
||||
|
||||
class Notification(models.Model):
|
||||
NOTICE = 0
|
||||
ALERT = 1
|
||||
EMERGENCY = 2
|
||||
|
||||
STATUS_CHOICES = (
|
||||
(NOTICE, "NOTICE"),
|
||||
(ALERT, "ALERT"),
|
||||
(EMERGENCY, "EMERGENCY")
|
||||
)
|
||||
|
||||
status = models.IntegerField("Status", choices=STATUS_CHOICES)
|
||||
text = models.CharField("Notification Text", max_length=1024)
|
||||
expiry = models.DateTimeField("Notification Expiry", null=True, blank=True)
|
||||
on_login = models.BooleanField("Display Notification on Login Screen", default=False)
|
||||
|
|
|
@ -277,7 +277,8 @@ def devices(request):
|
|||
"organization": orga,
|
||||
"devices": sorted(devices, key=lambda x: x.serial),
|
||||
"wifis": sorted(wifis, key=lambda x: x.serial),
|
||||
"users": sorted(users, key=lambda x: x.username)
|
||||
"users": sorted(users, key=lambda x: x.username),
|
||||
"notifications": getNotifications()
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
|
||||
<div align="center"><b>Manage:</b> <a id="linkdevices" href="#" onclick="showdevices();">Devices</a> ‐ <a id="linkwifi" href="#" onclick="showwifi();">WiFi</a>{% if user.is_staff %} ‐ <a id="linkusers" href="#" onclick="showusers();">Users</a>{% endif %}</div>
|
||||
|
||||
{% for notification in notifications %}
|
||||
<div class="alert alert-{% if notification.status == 0 %}info{% elif notification.status == 1 %}warning{% else %}danger{% endif %}">
|
||||
<strong>{% if notification.status == 0 %}Notice:{% elif notification.status == 1 %}Warning:{% else %}Emergency:{% endif %}</strong> {{ notification.text }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div name="devicespart" id="devicespart">
|
||||
<h2>Devices</h2>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% extends "two_factor/_base_focus.html" %}
|
||||
{% load i18n two_factor %}
|
||||
{% load notifications %}
|
||||
|
||||
{% block header %}
|
||||
{% if user.is_authenticated and not next %}
|
||||
|
@ -17,6 +18,7 @@
|
|||
</div>
|
||||
</noscript>
|
||||
|
||||
{% getNotifications %}
|
||||
|
||||
{% if wizard.steps.current == 'auth' %}
|
||||
{% if user.is_authenticated %}
|
||||
|
|
|
@ -7,7 +7,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
SECRET_KEY = '=go8&h#^kh6ksr11e2z-@4qqd6t%63$x#-!s#l_yhw@oyanrys'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ["admin360.kumi.host"]
|
||||
|
||||
|
|
Loading…
Reference in a new issue