Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
493c99ac
authored
Jul 29, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add vlan groups
parent
a351d5b5
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
126 additions
and
9 deletions
+126
-9
network/forms.py
+25
-1
network/tables.py
+14
-1
network/templates/network/columns/color-desc.html
+19
-0
network/templates/network/columns/vlan-list.html
+6
-0
network/templates/network/group-list.html
+1
-1
network/templates/network/menu.html
+10
-2
network/templates/network/vlan-group-edit.html
+14
-0
network/templates/network/vlan-group-list.html
+13
-0
network/urls.py
+5
-1
network/views.py
+19
-3
No files found.
network/forms.py
View file @
493c99ac
...
...
@@ -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
network/tables.py
View file @
493c99ac
...
...
@@ -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'
network/templates/network/columns/color-desc.html
0 → 100644
View file @
493c99ac
{% 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 }}
network/templates/network/columns/vlan-list.html
0 → 100644
View file @
493c99ac
{% load i18n %}
{% load l10n %}
{% for vlan in record.vlans.all %}
{{ vlan }}{% if not forloop.last %},{% endif %}
{% endfor %}
network/templates/network/group-list.html
View file @
493c99ac
...
...
@@ -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 %}
...
...
network/templates/network/menu.html
View file @
493c99ac
...
...
@@ -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>
#}
...
...
network/templates/network/vlan-group-edit.html
0 → 100644
View file @
493c99ac
{% 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 %}
network/templates/network/vlan-group-list.html
0 → 100644
View file @
493c99ac
{% 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 %}
network/urls.py
View file @
493c99ac
...
...
@@ -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'
),
)
network/views.py
View file @
493c99ac
...
...
@@ -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'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment