Commit a017e6cf by Őry Máté

network: add list of hosts to vlan-update

parent 1b082f78
...@@ -75,7 +75,6 @@ class VlanForm(ModelForm): ...@@ -75,7 +75,6 @@ class VlanForm(ModelForm):
helper.layout = Layout( helper.layout = Layout(
Div( Div(
Row( Row(
Div(
Fieldset( Fieldset(
'Identity', 'Identity',
'name', 'name',
...@@ -109,10 +108,6 @@ class VlanForm(ModelForm): ...@@ -109,10 +108,6 @@ class VlanForm(ModelForm):
# '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