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
d00fee67
authored
May 13, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: save vlan details
parent
214ba8d8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
17 deletions
+60
-17
cloud/urls.py
+1
-0
firewall_gui/static/partials/vlan-edit.html
+29
-17
firewall_gui/views.py
+30
-0
No files found.
cloud/urls.py
View file @
d00fee67
...
...
@@ -107,4 +107,5 @@ urlpatterns = patterns('',
url
(
r'^firewall/rules/save/$'
,
'firewall_gui.views.save_rule'
),
url
(
r'^firewall/hosts/save/$'
,
'firewall_gui.views.save_host'
),
url
(
r'^firewall/vlans/save/$'
,
'firewall_gui.views.save_vlan'
),
)
firewall_gui/static/partials/vlan-edit.html
View file @
d00fee67
...
...
@@ -6,10 +6,11 @@
<input
class=
"input-mini"
type=
"text"
id=
"ID"
placeholder=
"ID"
value=
"{{entity.id}}"
disabled=
"disabled"
>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('vid')"
>
<label
class=
"control-label"
for=
"VID"
>
VID
</label>
<div
class=
"controls"
>
<input
class=
"input-mini"
type=
"text"
id=
"VID"
placeholder=
"ID"
ng-model=
"entity.vid"
>
<span
class=
"help-inline"
ng-bind=
"getError('vid')"
></span>
</div>
</div>
<div
class=
"control-group"
>
...
...
@@ -24,80 +25,91 @@
<input
class=
"input"
type=
"text"
id=
"modified_at"
ng-model=
"entity.modified_at"
disabled=
"disabled"
>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('name')"
>
<label
class=
"control-label"
for=
"name"
>
Name
</label>
<div
class=
"controls"
>
<input
type=
"text"
id=
"name"
ng-model=
"entity.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('name')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('ipv4')"
>
<label
class=
"control-label"
for=
"ipv4"
>
IPv4
</label>
<div
class=
"controls"
>
<input
type=
"text"
id=
"ipv4"
ng-model=
"entity.ipv4"
/>
<span
class=
"help-inline"
ng-bind=
"getError('ipv4')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('ipv6')"
>
<label
class=
"control-label"
for=
"ipv6"
>
IPv6
</label>
<div
class=
"controls"
>
<input
type=
"text"
class=
"input-xlarge"
id=
"ipv6"
ng-model=
"entity.ipv6"
/>
<span
class=
"help-inline"
ng-bind=
"getError('ipv6')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
for=
"
nat
"
>
NAT
</label>
<div
class=
"control-group"
ng-class=
"hasError('snat_ip')"
>
<label
class=
"control-label"
for=
"
snat_ip
"
>
NAT
</label>
<div
class=
"controls"
>
<input
type=
"text"
id=
"nat"
ng-model=
"entity.nat"
/>
<input
type=
"text"
id=
"snat_ip"
ng-model=
"entity.nat"
/>
<span
class=
"help-inline"
ng-bind=
"getError('snat_ip')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('owner')"
>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"owner"
ng-model=
"entity.owner.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('owner')"
></span>
</div>
</div>
</div>
<div
class=
"span5"
>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('interface')"
>
<label
class=
"control-label"
for=
"interface"
>
Interface
</label>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"interface"
ng-model=
"entity.interface.name"
/>
<input
type=
"text"
autocomplete=
"off"
id=
"interface"
ng-model=
"entity.interface"
/>
<span
class=
"help-inline"
ng-bind=
"getError('interface')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('domain')"
>
<label
class=
"control-label"
for=
"domain"
>
Domain
</label>
<div
class=
"controls"
>
<input
type=
"text"
class=
"domain"
data-provide=
"typeahead"
autocomplete=
"off"
id=
"domain"
ng-model=
"entity.domain.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('domain')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('reverse_domain')"
>
<label
class=
"control-label"
for=
"reverse_domain"
>
Reverse domain
</label>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"reverse_domain"
ng-model=
"entity.reverse_domain.name"
/>
<input
type=
"text"
autocomplete=
"off"
id=
"reverse_domain"
ng-model=
"entity.reverse_domain"
/>
<span
class=
"help-inline"
ng-bind=
"getError('reverse_domain')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('description')"
>
<label
class=
"control-label"
for=
"description"
>
Description
</label>
<div
class=
"controls"
>
<textarea
rows=
"2"
id=
"description"
ng-model=
"entity.description"
>
</textarea>
<span
class=
"help-inline"
ng-bind=
"getError('description')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('comment')"
>
<label
class=
"control-label"
for=
"comment"
>
Comment
</label>
<div
class=
"controls"
>
<textarea
rows=
"2"
id=
"comment"
ng-model=
"entity.comment"
>
</textarea>
<span
class=
"help-inline"
ng-bind=
"getError('comment')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('dhcp_pool')"
>
<label
class=
"control-label"
for=
"dhcp_pool"
>
DHCP Pool
</label>
<div
class=
"controls"
>
<textarea
rows=
"2"
id=
"dhcp_pool"
ng-model=
"entity.dhcp_pool"
>
</textarea>
<span
class=
"help-inline"
ng-bind=
"getError('dhcp_pool')"
></span>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<button
type=
"submit"
class=
"btn"
>
Save (nem működik!)
</button>
<button
type=
"submit"
class=
"btn"
ng-click=
"save()"
>
Save
</button>
</div>
</div>
</div>
...
...
firewall_gui/views.py
View file @
d00fee67
...
...
@@ -454,3 +454,33 @@ def save_host(request):
return
HttpResponse
(
json
.
dumps
(
errors
),
content_type
=
'application/json'
,
status
=
400
)
host
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
def
save_vlan
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
vlan
=
get_object_or_404
(
Vlan
,
id
=
data
[
'id'
])
else
:
vlan
=
Vlan
.
objects
.
create
()
errors
=
{}
vlan
.
vid
=
data
[
'vid'
]
vlan
.
name
=
data
[
'name'
]
vlan
.
ipv4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
0
]
vlan
.
prefix4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
1
]
vlan
.
ipv6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
0
]
vlan
.
prefix6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
1
]
vlan
.
snat_ip
=
data
[
'nat'
]
vlan
.
description
=
data
[
'description'
]
vlan
.
comment
=
data
[
'comment'
]
vlan
.
reverse_domain
=
data
[
'reverse_domain'
]
vlan
.
dhcp_pool
=
data
[
'dhcp_pool'
]
vlan
.
interface
=
data
[
'interface'
]
set_field
(
vlan
,
'owner'
,
errors
,
username
=
data
[
'owner'
][
'name'
])
set_field
(
vlan
,
'domain'
,
errors
,
name
=
data
[
'domain'
][
'name'
])
try
:
vlan
.
full_clean
()
except
Exception
as
e
:
errors
=
dict
(
errors
.
items
()
+
e
.
message_dict
.
items
())
if
len
(
errors
)
>
0
:
return
HttpResponse
(
json
.
dumps
(
errors
),
content_type
=
'application/json'
,
status
=
400
)
vlan
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
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