Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5fa500ad
authored
Jul 24, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add group views
parent
1594a296
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
6 deletions
+93
-6
network/forms.py
+29
-1
network/tables.py
+11
-1
network/templates/network/group-edit.html
+14
-0
network/templates/network/group-list.html
+13
-0
network/templates/network/menu.html
+3
-0
network/urls.py
+3
-1
network/views.py
+20
-3
No files found.
network/forms.py
View file @
5fa500ad
...
@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper
...
@@ -5,7 +5,7 @@ from crispy_forms.helper import FormHelper
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Row
,
HTML
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Row
,
HTML
from
crispy_forms.layout
import
Div
,
ButtonHolder
,
Submit
,
BaseInput
from
crispy_forms.layout
import
Div
,
ButtonHolder
,
Submit
,
BaseInput
from
firewall.models
import
Host
,
Vlan
,
Domain
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
class
LinkButton
(
BaseInput
):
class
LinkButton
(
BaseInput
):
...
@@ -53,6 +53,34 @@ class DomainForm(ModelForm):
...
@@ -53,6 +53,34 @@ class DomainForm(ModelForm):
model
=
Domain
model
=
Domain
class
GroupForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Div
(
Row
(
Div
(
Fieldset
(
'Identity'
,
'name'
,
'description'
,
'owner'
,
),
css_class
=
'span8'
),
Div
(
HTML
(
'<p>hello</p>'
),
css_class
=
'span4'
),
),
ButtonHolder
(
Submit
(
'submit'
,
'Save'
),
LinkButton
(
'back'
,
'Back'
,
reverse_lazy
(
'network.group_list'
))
),
css_class
=
"form-horizontal"
))
class
Meta
:
model
=
Group
class
HostForm
(
ModelForm
):
class
HostForm
(
ModelForm
):
helper
=
FormHelper
()
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
helper
.
layout
=
Layout
(
...
...
network/tables.py
View file @
5fa500ad
from
django_tables2
import
Table
,
A
from
django_tables2
import
Table
,
A
from
django_tables2.columns
import
LinkColumn
from
django_tables2.columns
import
LinkColumn
from
firewall.models
import
Host
,
Vlan
,
Domain
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
class
DomainTable
(
Table
):
class
DomainTable
(
Table
):
...
@@ -14,6 +14,16 @@ class DomainTable(Table):
...
@@ -14,6 +14,16 @@ class DomainTable(Table):
order_by
=
(
'name'
,
)
order_by
=
(
'name'
,
)
class
GroupTable
(
Table
):
name
=
LinkColumn
(
'network.group'
,
args
=
[
A
(
'pk'
)])
class
Meta
:
model
=
Group
attrs
=
{
'class'
:
'table table-striped table-condensed'
}
fields
=
(
'name'
,
'description'
,
'owner'
,
)
order_by
=
(
'name'
,
)
class
HostTable
(
Table
):
class
HostTable
(
Table
):
hostname
=
LinkColumn
(
'network.host'
,
args
=
[
A
(
'pk'
)])
hostname
=
LinkColumn
(
'network.host'
,
args
=
[
A
(
'pk'
)])
...
...
network/templates/network/group-edit.html
0 → 100644
View file @
5fa500ad
{% 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 host
</small></h1>
</div>
{% crispy form %}
{% endblock %}
network/templates/network/group-list.html
0 → 100644
View file @
5fa500ad
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block content %}
<div
class=
"page-heading"
>
<h1>
Groups
<small>
list of all hosts
</small></h1>
</div>
{% render_table table %}
{% endblock %}
network/templates/network/menu.html
View file @
5fa500ad
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
{% include "network/menu-item.html" with href=u text="Vlans" %}
{% include "network/menu-item.html" with href=u text="Vlans" %}
{% url network.domain_list as u %}
{% url network.domain_list as u %}
{% include "network/menu-item.html" with href=u text="Domains" %}
{% 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" %}
{#
<li><a
href=
"/vlans/"
>
{% trans "Vlans" %}
</a></li>
#}
{#
<li><a
href=
"/vlans/"
>
{% trans "Vlans" %}
</a></li>
#}
{#
<li><a
href=
"/vlangroups/"
>
{% trans "Vlan groups" %}
</a></li>
#}
{#
<li><a
href=
"/vlangroups/"
>
{% trans "Vlan groups" %}
</a></li>
#}
...
...
network/urls.py
View file @
5fa500ad
from
django.conf.urls
import
patterns
,
url
from
django.conf.urls
import
patterns
,
url
from
.views
import
(
IndexView
,
HostList
,
HostDetail
,
VlanList
,
VlanDetail
,
from
.views
import
(
IndexView
,
HostList
,
HostDetail
,
VlanList
,
VlanDetail
,
DomainList
,
DomainDetail
)
DomainList
,
DomainDetail
,
GroupList
,
GroupDetail
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
...
@@ -10,6 +10,8 @@ urlpatterns = patterns(
...
@@ -10,6 +10,8 @@ urlpatterns = patterns(
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/(?P<pk>
\
d+)/$'
,
DomainDetail
.
as_view
(),
url
(
'^domains/(?P<pk>
\
d+)/$'
,
DomainDetail
.
as_view
(),
name
=
'network.domain'
),
name
=
'network.domain'
),
url
(
'^groups/$'
,
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
...
...
network/views.py
View file @
5fa500ad
...
@@ -4,9 +4,10 @@ from django.core.urlresolvers import reverse_lazy
...
@@ -4,9 +4,10 @@ from django.core.urlresolvers import reverse_lazy
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
from
firewall.models
import
Host
,
Vlan
,
Domain
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
from
.tables
import
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
from
.tables
import
(
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
from
.forms
import
HostForm
,
VlanForm
,
DomainForm
GroupTable
)
from
.forms
import
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
class
IndexView
(
TemplateView
):
class
IndexView
(
TemplateView
):
...
@@ -29,6 +30,22 @@ class DomainDetail(UpdateView):
...
@@ -29,6 +30,22 @@ class DomainDetail(UpdateView):
return
reverse_lazy
(
'network.domain'
,
kwargs
=
self
.
kwargs
)
return
reverse_lazy
(
'network.domain'
,
kwargs
=
self
.
kwargs
)
class
GroupList
(
SingleTableView
):
model
=
Group
table_class
=
GroupTable
template_name
=
"network/group-list.html"
class
GroupDetail
(
UpdateView
):
model
=
Group
template_name
=
"network/group-edit.html"
form_class
=
GroupForm
def
get_success_url
(
self
):
if
'pk'
in
self
.
kwargs
:
return
reverse_lazy
(
'network.group'
,
kwargs
=
self
.
kwargs
)
class
HostList
(
SingleTableView
):
class
HostList
(
SingleTableView
):
model
=
Host
model
=
Host
table_class
=
HostTable
table_class
=
HostTable
...
...
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