Commit 493c99ac by Kálmán Viktor

network: add vlan groups

parent a351d5b5
......@@ -6,7 +6,7 @@ from crispy_forms.layout import Layout, Fieldset, Row, HTML
from crispy_forms.layout import Div, ButtonHolder, Submit, BaseInput
from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist,
Rule)
Rule, VlanGroup)
class LinkButton(BaseInput):
......@@ -283,3 +283,27 @@ class VlanForm(ModelForm):
class Meta:
model = Vlan
class VlanGroupForm(ModelForm):
helper = FormHelper()
helper.layout = Layout(
Div(
Row(
Fieldset(
'Identity',
'name',
'vlans',
'description',
'owner',
),
),
ButtonHolder(
Submit('submit', 'Save'),
LinkButton('back', 'Back', reverse_lazy(
'network.vlan_group_list'))
),
css_class="form-horizontal"))
class Meta:
model = VlanGroup
......@@ -70,7 +70,9 @@ class RecordTable(Table):
class RuleTable(Table):
r_type = LinkColumn('network.rule', args=[A('pk')])
color_desc = TemplateColumn(template_name="network/color_desc.html")
color_desc = TemplateColumn(
template_name="network/columns/color-desc.html"
)
class Meta:
model = Rule
......@@ -88,3 +90,14 @@ class VlanTable(Table):
attrs = {'class': 'table table-striped table-condensed'}
fields = ('vid', 'name', 'interface', 'ipv4', 'ipv6', 'domain', )
order_by = 'vid'
class VlanGroupTable(Table):
name = LinkColumn('network.vlan_group', args=[A('pk')])
vlans = TemplateColumn(template_name="network/columns/vlan-list.html")
class Meta:
model = Vlan
attrs = {'class': 'table table-striped table-condensed'}
fields = ('name', 'vlans', 'description', 'owner', )
order_by = 'name'
{% load i18n %}
{% load l10n %}
<span style="color: #FF0000;">[{{ record.r_type }}]</span>
{% if record.direction == "1" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %}
{#<span style="color: #0000FF;"> ▸ </span>#}
<i class="icon-arrow-right"></i>
{% if record.direction == "0" %}{{ record.foreign_network }}{% else %}{{ record.r_type }}{% endif %}
<span style="color: #00FF00;">
{% if record.proto %}
proto={{ record.proto }}
{% endif %}
{% if record.sport %}
sport={{ record.sport }}
{% endif %}
{% if record.dport %}
dport={{ record.dport }}
{% endif %}
{{ record.description }}
{% load i18n %}
{% load l10n %}
{% for vlan in record.vlans.all %}
{{ vlan }}{% if not forloop.last %},{% endif %}
{% endfor %}
......@@ -6,7 +6,7 @@
{% block content %}
<div class="page-heading">
<h1>Groups <small>list of all groups</small></h1>
<h1>Host groups <small>list of all host groups</small></h1>
</div>
{% render_table table %}
......
......@@ -7,8 +7,6 @@
{% include "network/menu-item.html" with href=u text="Vlans" %}
{% url network.domain_list as u %}
{% include "network/menu-item.html" with href=u text="Domains" %}
{% url network.group_list as u %}
{% include "network/menu-item.html" with href=u text="Groups" %}
{% url network.record_list as u %}
{% include "network/menu-item.html" with href=u text="Records" %}
{% url network.blacklist_list as u %}
......@@ -16,6 +14,16 @@
{% url network.rule_list as u %}
{% include "network/menu-item.html" with href=u text="Rules" %}
<li class="dropdown{% if "groups" in request.path %} active{% endif %}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Groups <b class="caret"></b></a>
<ul class="dropdown-menu">
{% url network.vlan_group_list as u %}
{% include "network/menu-item.html" with href=u text="Vlan groups" %}
{% url network.group_list as u %}
{% include "network/menu-item.html" with href=u text="Host groups" %}
</ul>
</li>
{# <li><a href="/vlans/">{% trans "Vlans" %}</a></li> #}
{# <li><a href="/vlangroups/">{% trans "Vlan groups" %}</a></li> #}
......
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block content %}
<div class="page-heading">
<h1>{{ form.name.value }} <small>details of vlan group</small></h1>
</div>
{% crispy form %}
{% endblock %}
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block content %}
<div class="page-heading">
<h1>Vlan groups <small>list of all vlan groups</small></h1>
</div>
{% render_table table %}
{% endblock %}
......@@ -3,7 +3,7 @@ from django.conf.urls import patterns, url
from .views import (IndexView, HostList, HostDetail, VlanList, VlanDetail,
DomainList, DomainDetail, GroupList, GroupDetail,
RecordList, RecordDetail, BlacklistList, BlacklistDetail,
RuleList, RuleDetail)
RuleList, RuleDetail, VlanGroupList, VlanGroupDetail)
urlpatterns = patterns(
......@@ -28,4 +28,8 @@ urlpatterns = patterns(
name='network.rule'),
url('^vlans/$', VlanList.as_view(), name='network.vlan_list'),
url('^vlans/(?P<vid>\d+)/$', VlanDetail.as_view(), name='network.vlan'),
url('^vlangroups/$', VlanGroupList.as_view(),
name='network.vlan_group_list'),
url('^vlangroups/(?P<pk>\d+)/$', VlanGroupDetail.as_view(),
name='network.vlan_group'),
)
......@@ -5,11 +5,12 @@ from django.core.urlresolvers import reverse_lazy
from django_tables2 import SingleTableView
from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist,
Rule)
Rule, VlanGroup)
from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable,
GroupTable, RecordTable, BlacklistTable, RuleTable)
GroupTable, RecordTable, BlacklistTable, RuleTable,
VlanGroupTable)
from .forms import (HostForm, VlanForm, DomainForm, GroupForm, RecordForm,
BlacklistForm, RuleForm)
BlacklistForm, RuleForm, VlanGroupForm)
from itertools import chain
......@@ -191,3 +192,18 @@ class VlanDetail(UpdateView):
return context
success_url = reverse_lazy('network.vlan_list')
class VlanGroupList(SingleTableView):
model = VlanGroup
table_class = VlanGroupTable
template_name = "network/vlan-group-list.html"
table_pagination = False
class VlanGroupDetail(UpdateView):
model = VlanGroup
template_name = "network/vlan-group-edit.html"
form_class = VlanGroupForm
success_url = reverse_lazy('network.vlan_group_list')
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