Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
f4ef13d8
authored
Jul 24, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: add record views
parent
acd0d3fe
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
106 additions
and
7 deletions
+106
-7
network/forms.py
+34
-1
network/tables.py
+13
-1
network/templates/network/menu.html
+2
-1
network/templates/network/record-edit.html
+14
-0
network/templates/network/record-list.html
+13
-0
network/urls.py
+5
-1
network/views.py
+25
-3
No files found.
network/forms.py
View file @
f4ef13d8
...
...
@@ -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
,
Vlan
,
Domain
,
Group
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
,
Record
class
LinkButton
(
BaseInput
):
...
...
@@ -127,6 +127,39 @@ class HostForm(ModelForm):
model
=
Host
class
RecordForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Div
(
Row
(
Div
(
Fieldset
(
'Identity'
,
'name'
,
'domain'
,
'type'
,
'address'
,
'ttl'
,
'host'
,
'description'
,
'owner'
,
),
css_class
=
'span8'
),
Div
(
HTML
(
'<p>hello</p>'
),
css_class
=
'span4'
),
),
ButtonHolder
(
Submit
(
'submit'
,
'Save'
),
LinkButton
(
'back'
,
'Back'
,
reverse_lazy
(
'network.record_list'
))
),
css_class
=
"form-horizontal"
))
class
Meta
:
model
=
Record
class
VlanForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
...
...
network/tables.py
View file @
f4ef13d8
from
django_tables2
import
Table
,
A
from
django_tables2.columns
import
LinkColumn
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
,
Record
class
DomainTable
(
Table
):
...
...
@@ -46,6 +46,18 @@ class SmallHostTable(Table):
order_by
=
(
'vlan'
,
'hostname'
,
)
class
RecordTable
(
Table
):
fqdn
=
LinkColumn
(
'network.record'
,
args
=
[
A
(
'pk'
)])
class
Meta
:
model
=
Record
attrs
=
{
'class'
:
'table table-striped table-condensed'
}
fields
=
(
'type'
,
'fqdn'
,
'address'
,
'ttl'
,
'host'
,
'owner'
,
)
sequence
=
(
'type'
,
'fqdn'
,
)
order_by
=
'name'
class
VlanTable
(
Table
):
name
=
LinkColumn
(
'network.vlan'
,
args
=
[
A
(
'vid'
)])
...
...
network/templates/network/menu.html
View file @
f4ef13d8
...
...
@@ -9,7 +9,8 @@
{% 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" %}
{#
<li><a
href=
"/vlans/"
>
{% trans "Vlans" %}
</a></li>
#}
{#
<li><a
href=
"/vlangroups/"
>
{% trans "Vlan groups" %}
</a></li>
#}
...
...
network/templates/network/record-edit.html
0 → 100644
View file @
f4ef13d8
{% 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>
{{ fqdn }}
<small>
details of record
</small></h1>
</div>
{% crispy form %}
{% endblock %}
network/templates/network/record-list.html
0 → 100644
View file @
f4ef13d8
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block content %}
<div
class=
"page-heading"
>
<h1>
Records
<small>
list of all records
</small></h1>
</div>
{% render_table table %}
{% endblock %}
network/urls.py
View file @
f4ef13d8
from
django.conf.urls
import
patterns
,
url
from
.views
import
(
IndexView
,
HostList
,
HostDetail
,
VlanList
,
VlanDetail
,
DomainList
,
DomainDetail
,
GroupList
,
GroupDetail
)
DomainList
,
DomainDetail
,
GroupList
,
GroupDetail
,
RecordList
,
RecordDetail
)
urlpatterns
=
patterns
(
...
...
@@ -14,6 +15,9 @@ urlpatterns = patterns(
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^records/$'
,
RecordList
.
as_view
(),
name
=
'network.record_list'
),
url
(
'^records/(?P<pk>
\
d+)/$'
,
RecordDetail
.
as_view
(),
name
=
'network.record'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
)
network/views.py
View file @
f4ef13d8
...
...
@@ -4,10 +4,10 @@ from django.core.urlresolvers import reverse_lazy
from
django_tables2
import
SingleTableView
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
from
firewall.models
import
Host
,
Vlan
,
Domain
,
Group
,
Record
from
.tables
import
(
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
GroupTable
)
from
.forms
import
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
GroupTable
,
RecordTable
)
from
.forms
import
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
,
RecordForm
class
IndexView
(
TemplateView
):
...
...
@@ -78,6 +78,28 @@ class HostDetail(UpdateView):
return
reverse_lazy
(
'network.host'
,
kwargs
=
self
.
kwargs
)
class
RecordList
(
SingleTableView
):
model
=
Record
table_class
=
RecordTable
template_name
=
"network/record-list.html"
class
RecordDetail
(
UpdateView
):
model
=
Record
template_name
=
"network/record-edit.html"
form_class
=
RecordForm
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
RecordDetail
,
self
)
.
get_context_data
(
**
kwargs
)
q
=
Record
.
objects
.
get
(
pk
=
self
.
object
.
pk
)
.
fqdn
context
[
'fqdn'
]
=
q
return
context
def
get_success_url
(
self
):
if
'pk'
in
self
.
kwargs
:
return
reverse_lazy
(
'network.record'
,
kwargs
=
self
.
kwargs
)
class
VlanList
(
SingleTableView
):
model
=
Vlan
table_class
=
VlanTable
...
...
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