Commit a017e6cf by Őry Máté

network: add list of hosts to vlan-update

parent 1b082f78
......@@ -75,44 +75,39 @@ class VlanForm(ModelForm):
helper.layout = Layout(
Div(
Row(
Div(
Fieldset(
'Identity',
'name',
'vid',
'interface',
),
Fieldset(
'IPv4',
'net4',
'prefix4',
'ipv4',
'snat_to',
'snat_ip',
'dhcp_pool',
),
Fieldset(
'IPv6',
'net6',
'prefix6',
'ipv6',
),
Fieldset(
'Domain name service',
'domain',
'reverse_domain',
),
Fieldset(
'Info',
'description',
'comment',
# 'created_at',
# 'modified_at',
),
css_class='span8'),
Div(
HTML('<p>hello</p>'),
css_class='span4'),
Fieldset(
'Identity',
'name',
'vid',
'interface',
),
Fieldset(
'IPv4',
'net4',
'prefix4',
'ipv4',
'snat_to',
'snat_ip',
'dhcp_pool',
),
Fieldset(
'IPv6',
'net6',
'prefix6',
'ipv6',
),
Fieldset(
'Domain name service',
'domain',
'reverse_domain',
),
Fieldset(
'Info',
'description',
'comment',
# 'created_at',
# 'modified_at',
),
),
ButtonHolder(
Submit('submit', 'Save'),
......
......@@ -15,6 +15,17 @@ class HostTable(Table):
order_by = ('vlan', 'hostname', )
# inheritance by copy-paste
class SmallHostTable(Table):
hostname = LinkColumn('network.host', args=[A('pk')])
class Meta:
model = Host
attrs = {'class': 'table table-striped table-condensed'}
fields = ('hostname', 'ipv4')
order_by = ('vlan', 'hostname', )
class VlanTable(Table):
name = LinkColumn('network.vlan', args=[A('pk')])
......
......@@ -7,8 +7,15 @@
{% block content %}
<div class="page-heading">
<h1>{{ form.hostname.value }} <small>details of host</small></h1>
<h1>{{ form.name.value }} <small>details of vlan</small></h1>
</div>
<div class="row">
<div class="span8">
{% crispy form %}
</div>
<div class="span4">
{% render_table host_list %}
</div>
</div>
{% endblock %}
......@@ -4,7 +4,7 @@ from django.views.generic import UpdateView
from django_tables2 import SingleTableView
from firewall.models import Host, Vlan
from .tables import HostTable, VlanTable
from .tables import HostTable, VlanTable, SmallHostTable
from .forms import HostForm, VlanForm
......@@ -34,3 +34,9 @@ class VlanDetail(UpdateView):
model = Vlan
template_name = "network/vlan-edit.html"
form_class = VlanForm
def get_context_data(self, **kwargs):
context = super(VlanDetail, self).get_context_data(**kwargs)
q = Host.objects.filter(vlan=self.object).all()
context['host_list'] = SmallHostTable(q)
return context
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