Commit a017e6cf by Őry Máté

network: add list of hosts to vlan-update

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