Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
5662eacd
authored
May 17, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: save record&domain details
parent
805181a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
cloud/urls.py
+2
-0
firewall_gui/views.py
+43
-0
No files found.
cloud/urls.py
View file @
5662eacd
...
...
@@ -112,4 +112,6 @@ urlpatterns = patterns('',
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'
),
url
(
r'^firewall/domains/save/$'
,
'firewall_gui.views.save_domain'
),
url
(
r'^firewall/records/save/$'
,
'firewall_gui.views.save_record'
),
)
firewall_gui/views.py
View file @
5662eacd
...
...
@@ -618,3 +618,46 @@ def save_hostgroup(request):
return
HttpResponse
(
json
.
dumps
(
errors
),
content_type
=
'application/json'
,
status
=
400
)
hostgroup
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
@user_passes_test
(
req_staff
)
def
save_domain
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
domain
=
get_object_or_404
(
Domain
,
id
=
data
[
'id'
])
else
:
domain
=
Domain
.
objects
.
create
()
errors
=
{}
domain
.
name
=
data
[
'name'
]
domain
.
ttl
=
data
[
'ttl'
]
domain
.
description
=
data
[
'description'
]
set_field
(
domain
,
'owner'
,
errors
,
username
=
data
[
'owner'
][
'name'
])
try
:
domain
.
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
)
domain
.
save
()
return
HttpResponse
(
'KTHXBYE'
)
@user_passes_test
(
req_staff
)
def
save_record
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
record
=
get_object_or_404
(
Record
,
id
=
data
[
'id'
])
else
:
record
=
Record
.
objects
.
create
()
errors
=
{}
record
.
name
=
data
[
'name'
]
record
.
ttl
=
data
[
'ttl'
]
record
.
description
=
data
[
'description'
]
set_field
(
record
,
'owner'
,
errors
,
username
=
data
[
'owner'
][
'name'
])
set_field
(
record
,
'domain'
,
errors
,
name
=
data
[
'domain'
][
'name'
])
try
:
record
.
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
)
record
.
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