Commit 8f0735c7 by Őry Máté

network: add unregistered dhcp clients table

parent ec0e901c
......@@ -122,6 +122,20 @@ class SmallHostTable(Table):
attrs = {'class': 'table table-striped table-condensed'}
fields = ('hostname', 'ipv4')
order_by = ('vlan', 'hostname', )
empty_text = _("No hosts.")
class SmallDhcpTable(Table):
mac = MACColumn(verbose_name=_("MAC address"))
hostname = Column(verbose_name=_("hostname"))
ip = Column(verbose_name=_("requested IP"))
register = TemplateColumn(
attrs={"th": {"style": "display: none;"}})
class Meta:
attrs = {'class': 'table table-striped table-condensed'}
empty_text = _("No hosts.")
class RecordTable(Table):
{% load i18n %}
<a href="{% url "network.host_create" %}?vlan={{ }}&amp;mac={{ record.mac }}&amp;hostname={{ record.hostname }}&amp;ipv4={{ record.ip }}"
title="{% trans "register host" %}"><i class="fa fa-plus-circle"></i></a>
......@@ -22,6 +22,12 @@
<h3>{% trans "Host list" %}</h3>
{% render_table host_list %}
<div class="page-header">
<h3>{% trans "Unregistered hosts" %}</h3>
{% render_table dhcp_list %}
<div class="page-header">
<h3>{% trans "Manage access" %}</h3>
......@@ -20,7 +20,7 @@ from django.views.generic import (TemplateView, UpdateView, DeleteView,
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from django_tables2 import SingleTableView
......@@ -30,7 +30,7 @@ from vm.models import Interface
from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable,
GroupTable, RecordTable, BlacklistItemTable, RuleTable,
VlanGroupTable, SmallRuleTable, SmallGroupRuleTable,
SmallRecordTable, SwitchPortTable)
SmallRecordTable, SwitchPortTable, SmallDhcpTable, )
from .forms import (HostForm, VlanForm, DomainForm, GroupForm, RecordForm,
BlacklistItemForm, RuleForm, VlanGroupForm, SwitchPortForm)
......@@ -434,6 +434,8 @@ class HostCreate(LoginRequiredMixin, SuperuserRequiredMixin,
if i in self.request.GET and i not in self.request.POST:
initial[i] = self.request.GET[i]
if "vlan" in initial:
if not initial['vlan'].isnumeric():
raise Http404()
vlan = get_object_or_404(Vlan.objects, pk=initial['vlan'])
......@@ -711,6 +713,7 @@ class VlanDetail(LoginRequiredMixin, SuperuserRequiredMixin,
def get_context_data(self, **kwargs):
context = super(VlanDetail, self).get_context_data(**kwargs)
context['host_list'] = SmallHostTable(self.object.host_set.all())
context['dhcp_list'] = SmallDhcpTable(self.object.get_dhcp_clients())
context['vlan_vid'] = self.kwargs.get('vid')
context['acl'] = AclUpdateView.get_acl_data(
self.object, self.request.user, 'network.vlan-acl')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment