Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
91d35ea6
authored
Jul 15, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add vlan views
parent
edf54253
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
6 deletions
+112
-6
network/forms.py
+56
-1
network/tables.py
+11
-1
network/templates/network/vlan-edit.html
+14
-0
network/templates/network/vlan-list.html
+13
-0
network/urls.py
+3
-1
network/views.py
+15
-3
No files found.
network/forms.py
View file @
91d35ea6
...
...
@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Row
,
HTML
from
crispy_forms.layout
import
Div
,
ButtonHolder
,
Submit
,
BaseInput
from
firewall.models
import
Host
from
firewall.models
import
Host
,
Vlan
class
LinkButton
(
BaseInput
):
...
...
@@ -68,3 +68,58 @@ class HostForm(ModelForm):
class
Meta
:
model
=
Host
class
VlanForm
(
ModelForm
):
helper
=
FormHelper
()
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'
),
),
ButtonHolder
(
Submit
(
'submit'
,
'Save'
),
LinkButton
(
'back'
,
'Back'
,
reverse_lazy
(
'network.host_list'
))
),
css_class
=
"form-horizontal"
))
class
Meta
:
model
=
Vlan
network/tables.py
View file @
91d35ea6
from
django_tables2
import
Table
,
A
from
django_tables2.columns
import
LinkColumn
from
firewall.models
import
Host
from
firewall.models
import
Host
,
Vlan
class
HostTable
(
Table
):
hostname
=
LinkColumn
(
'network.host'
,
args
=
[
A
(
'pk'
)])
...
...
@@ -12,3 +13,12 @@ class HostTable(Table):
fields
=
(
'hostname'
,
'vlan'
,
'mac'
,
'ipv4'
,
'ipv6'
,
'pub_ipv4'
,
'created_at'
,
'owner'
,
)
class
VlanTable
(
Table
):
name
=
LinkColumn
(
'network.vlan'
,
args
=
[
A
(
'pk'
)])
class
Meta
:
model
=
Vlan
attrs
=
{
'class'
:
'table table-striped table-condensed'
}
fields
=
(
'vid'
,
'name'
,
'interface'
,
'ipv4'
,
'ipv6'
,
'domain'
,
)
order_by
=
'vid'
network/templates/network/vlan-edit.html
0 → 100644
View file @
91d35ea6
{% 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.hostname.value }}
<small>
details of host
</small></h1>
</div>
{% crispy form %}
{% endblock %}
network/templates/network/vlan-list.html
0 → 100644
View file @
91d35ea6
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block content %}
<div
class=
"page-heading"
>
<h1>
Hosts
<small>
list of all hosts
</small></h1>
</div>
{% render_table table %}
{% endblock %}
network/urls.py
View file @
91d35ea6
from
django.conf.urls
import
patterns
,
url
from
.views
import
IndexView
,
HostList
,
HostDetail
from
.views
import
IndexView
,
HostList
,
HostDetail
,
VlanList
,
VlanDetail
urlpatterns
=
patterns
(
...
...
@@ -8,4 +8,6 @@ urlpatterns = patterns(
url
(
'^$'
,
IndexView
.
as_view
(),
name
=
'network.index'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/(?P<pk>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
)
network/views.py
View file @
91d35ea6
...
...
@@ -3,9 +3,9 @@ from django.views.generic import UpdateView
from
django_tables2
import
SingleTableView
from
firewall.models
import
Host
from
.tables
import
HostTable
from
.forms
import
HostForm
from
firewall.models
import
Host
,
Vlan
from
.tables
import
HostTable
,
VlanTable
from
.forms
import
HostForm
,
VlanForm
class
IndexView
(
TemplateView
):
...
...
@@ -22,3 +22,15 @@ class HostDetail(UpdateView):
model
=
Host
template_name
=
"network/host-edit.html"
form_class
=
HostForm
class
VlanList
(
SingleTableView
):
model
=
Vlan
table_class
=
VlanTable
template_name
=
"network/vlan-list.html"
class
VlanDetail
(
UpdateView
):
model
=
Vlan
template_name
=
"network/vlan-edit.html"
form_class
=
VlanForm
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