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
f99474fe
authored
May 13, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: save vlan/hostgroup details
parent
6ec6913c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
9 deletions
+61
-9
cloud/urls.py
+2
-0
firewall_gui/static/partials/hostgroup-edit.html
+7
-4
firewall_gui/static/partials/vlangroup-edit.html
+9
-5
firewall_gui/views.py
+43
-0
No files found.
cloud/urls.py
View file @
f99474fe
...
@@ -108,4 +108,6 @@ urlpatterns = patterns('',
...
@@ -108,4 +108,6 @@ urlpatterns = patterns('',
url
(
r'^firewall/rules/save/$'
,
'firewall_gui.views.save_rule'
),
url
(
r'^firewall/rules/save/$'
,
'firewall_gui.views.save_rule'
),
url
(
r'^firewall/hosts/save/$'
,
'firewall_gui.views.save_host'
),
url
(
r'^firewall/hosts/save/$'
,
'firewall_gui.views.save_host'
),
url
(
r'^firewall/vlans/save/$'
,
'firewall_gui.views.save_vlan'
),
url
(
r'^firewall/vlans/save/$'
,
'firewall_gui.views.save_vlan'
),
url
(
r'^firewall/vlangroups/save/$'
,
'firewall_gui.views.save_vlangroup'
),
url
(
r'^firewall/hostgroups/save/$'
,
'firewall_gui.views.save_hostgroup'
),
)
)
firewall_gui/static/partials/hostgroup-edit.html
View file @
f99474fe
...
@@ -18,30 +18,33 @@
...
@@ -18,30 +18,33 @@
<input
class=
"input"
type=
"text"
id=
"modified_at"
ng-model=
"entity.modified_at"
disabled=
"disabled"
>
<input
class=
"input"
type=
"text"
id=
"modified_at"
ng-model=
"entity.modified_at"
disabled=
"disabled"
>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('name')"
>
<label
class=
"control-label"
for=
"name"
>
Name
</label>
<label
class=
"control-label"
for=
"name"
>
Name
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
type=
"text"
id=
"name"
ng-model=
"entity.name"
/>
<input
type=
"text"
id=
"name"
ng-model=
"entity.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('name')"
></span>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"span5"
>
<div
class=
"span5"
>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('owner')"
>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"owner"
ng-model=
"entity.owner.name"
/>
<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>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('description')"
>
<label
class=
"control-label"
for=
"description"
>
Description
</label>
<label
class=
"control-label"
for=
"description"
>
Description
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<textarea
rows=
"4"
id=
"description"
ng-model=
"entity.description"
>
<textarea
rows=
"4"
id=
"description"
ng-model=
"entity.description"
>
<span
class=
"help-inline"
ng-bind=
"getError('description')"
></span>
</textarea>
</textarea>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<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>
</div>
</div>
</div>
...
...
firewall_gui/static/partials/vlangroup-edit.html
View file @
f99474fe
...
@@ -18,28 +18,31 @@
...
@@ -18,28 +18,31 @@
<input
class=
"input"
type=
"text"
id=
"modified_at"
ng-model=
"entity.modified_at"
disabled=
"disabled"
>
<input
class=
"input"
type=
"text"
id=
"modified_at"
ng-model=
"entity.modified_at"
disabled=
"disabled"
>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('name')"
>
<label
class=
"control-label"
for=
"name"
>
Name
</label>
<label
class=
"control-label"
for=
"name"
>
Name
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
type=
"text"
id=
"name"
ng-model=
"entity.name"
/>
<input
type=
"text"
id=
"name"
ng-model=
"entity.name"
/>
<span
class=
"help-inline"
ng-bind=
"getError('name')"
></span>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('owner')"
>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<label
class=
"control-label"
for=
"owner"
>
Owner
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<input
type=
"text"
autocomplete=
"off"
id=
"owner"
ng-model=
"entity.owner.name"
/>
<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>
</div>
</div>
<div
class=
"span5"
>
<div
class=
"span5"
>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('description')"
>
<label
class=
"control-label"
for=
"description"
>
Description
</label>
<label
class=
"control-label"
for=
"description"
>
Description
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<textarea
rows=
"2"
id=
"description"
ng-model=
"entity.description"
>
<textarea
rows=
"2"
id=
"description"
ng-model=
"entity.description"
>
</textarea>
</textarea>
<span
class=
"help-inline"
ng-bind=
"getError('description')"
></span>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
ng-class=
"hasError('vlangroups')"
>
<label
class=
"control-label"
for=
"vlangroups"
>
Vlans
</label>
<label
class=
"control-label"
for=
"vlangroups"
>
Vlans
</label>
<div
class=
"controls"
>
<div
class=
"controls"
>
<div
class=
"well well-small"
>
<div
class=
"well well-small"
>
...
@@ -51,12 +54,13 @@
...
@@ -51,12 +54,13 @@
<div
class=
"input-append"
>
<div
class=
"input-append"
>
<input
class=
"span2 vlan"
id=
"vlan"
type=
"text"
data-provide=
"typeahead"
>
<input
class=
"span2 vlan"
id=
"vlan"
type=
"text"
data-provide=
"typeahead"
>
<button
class=
"btn"
type=
"button"
>
Add
</button>
<button
class=
"btn"
type=
"button"
>
Add
</button>
<span
class=
"help-inline"
ng-bind=
"getError('vlangroups')"
></span>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<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>
</div>
</div>
</div>
...
...
firewall_gui/views.py
View file @
f99474fe
...
@@ -459,6 +459,7 @@ def save_host(request):
...
@@ -459,6 +459,7 @@ def save_host(request):
host
.
save
()
host
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
return
HttpResponse
(
'KTHXBYE'
)
@user_passes_test
(
req_staff
)
def
save_vlan
(
request
):
def
save_vlan
(
request
):
data
=
json
.
loads
(
request
.
body
)
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
if
data
[
'id'
]:
...
@@ -488,3 +489,45 @@ def save_vlan(request):
...
@@ -488,3 +489,45 @@ def save_vlan(request):
return
HttpResponse
(
json
.
dumps
(
errors
),
content_type
=
'application/json'
,
status
=
400
)
return
HttpResponse
(
json
.
dumps
(
errors
),
content_type
=
'application/json'
,
status
=
400
)
vlan
.
save
()
vlan
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
return
HttpResponse
(
'KTHXBYE'
)
@user_passes_test
(
req_staff
)
def
save_vlangroup
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
vlangroup
=
get_object_or_404
(
VlanGroup
,
id
=
data
[
'id'
])
else
:
vlangroup
=
VlanGroup
.
objects
.
create
()
errors
=
{}
vlangroup
.
name
=
data
[
'name'
]
vlangroup
.
description
=
data
[
'description'
]
# TODO: save vlans
set_field
(
vlangroup
,
'owner'
,
errors
,
username
=
data
[
'owner'
][
'name'
])
try
:
vlangroup
.
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
)
vlangroup
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
@user_passes_test
(
req_staff
)
def
save_hostgroup
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
hostgroup
=
get_object_or_404
(
Group
,
id
=
data
[
'id'
])
else
:
hostgroup
=
Group
.
objects
.
create
()
errors
=
{}
hostgroup
.
name
=
data
[
'name'
]
hostgroup
.
description
=
data
[
'description'
]
# TODO: save hosts
set_field
(
hostgroup
,
'owner'
,
errors
,
username
=
data
[
'owner'
][
'name'
])
try
:
hostgroup
.
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
)
hostgroup
.
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