modified: netbox_dns_bridge/navigation.py
new file: netbox_dns_bridge/templates/netbox_dns_bridge/catz_overview.html deleted: netbox_dns_bridge/templates/netbox_dns_bridge/info.html new file: netbox_dns_bridge/templates/netbox_dns_bridge/notify_overview.html modified: netbox_dns_bridge/urls.py modified: netbox_dns_bridge/views.py Extend views
This commit is contained in:
1 parent
60bc60ccc4
commit
9f71ff7332
6 files changed
+157
-112
No files matched your search
+37
-17
@@ -1,43 +1,63 @@
|
||||
from django.views import View
|
||||
from collections import OrderedDict
|
||||
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.shortcuts import render
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
||||
from .models import IntegerKeyValueSetting, SeenTransferClients
|
||||
|
||||
|
||||
class InfoView(View):
|
||||
template_name = "netbox_dns_bridge/info.html"
|
||||
@method_decorator(
|
||||
user_passes_test(lambda u: u.is_superuser), name="dispatch"
|
||||
)
|
||||
class CatzOverviewView(View):
|
||||
template_name = "netbox_dns_bridge/catz_overview.html"
|
||||
|
||||
def get(self, request):
|
||||
import netbox_dns.models
|
||||
|
||||
settings_rows = IntegerKeyValueSetting.objects.all().order_by("key")
|
||||
soa_serial_obj = IntegerKeyValueSetting.objects.filter(
|
||||
key="catalog-zone-soa-serial"
|
||||
).first()
|
||||
soa_serial = soa_serial_obj.value if soa_serial_obj else None
|
||||
|
||||
seen_clients = (
|
||||
SeenTransferClients.objects.select_related("view")
|
||||
.all()
|
||||
.order_by("source_ip")
|
||||
)
|
||||
|
||||
zones = []
|
||||
zones_grouped = OrderedDict()
|
||||
for z in netbox_dns.models.Zone.objects.select_related(
|
||||
"view", "catz_identifier"
|
||||
).order_by("name"):
|
||||
).order_by("view__name", "name"):
|
||||
view_name = z.view.name if z.view else ""
|
||||
view_display = view_name[0].upper() + view_name[1:] if view_name else ""
|
||||
try:
|
||||
catz_identifier = z.catz_identifier.name
|
||||
except netbox_dns.models.Zone.catz_identifier.RelatedObjectDoesNotExist:
|
||||
catz_identifier = None
|
||||
zones.append(
|
||||
zones_grouped.setdefault(view_display, []).append(
|
||||
{
|
||||
"name": z.name,
|
||||
"view": z.view.name if z.view else None,
|
||||
"active": z.active,
|
||||
"catz_identifier": catz_identifier,
|
||||
}
|
||||
)
|
||||
|
||||
context = {
|
||||
"settings_rows": settings_rows,
|
||||
"seen_clients": seen_clients,
|
||||
"zones": zones,
|
||||
"soa_serial": soa_serial,
|
||||
"zones_grouped": zones_grouped,
|
||||
}
|
||||
return render(request, self.template_name, context)
|
||||
|
||||
|
||||
@method_decorator(
|
||||
user_passes_test(lambda u: u.is_superuser), name="dispatch"
|
||||
)
|
||||
class NotifyOverviewView(View):
|
||||
template_name = "netbox_dns_bridge/notify_overview.html"
|
||||
|
||||
def get(self, request):
|
||||
seen_clients = (
|
||||
SeenTransferClients.objects.select_related("view")
|
||||
.all()
|
||||
.order_by("source_ip")
|
||||
)
|
||||
context = {"seen_clients": seen_clients}
|
||||
return render(request, self.template_name, context)
|
||||
Reference in new issue
Block a user