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
4a295ff8
authored
May 08, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: save rule
parent
c0a19e60
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
1 deletions
+41
-1
cloud/urls.py
+2
-0
firewall_gui/static/js/project.js
+12
-0
firewall_gui/static/partials/rule-edit.html
+1
-1
firewall_gui/views.py
+26
-0
No files found.
cloud/urls.py
View file @
4a295ff8
...
@@ -117,4 +117,6 @@ urlpatterns = patterns('',
...
@@ -117,4 +117,6 @@ urlpatterns = patterns('',
url
(
r'^firewall/autocomplete/firewall/$'
,
'firewall_gui.views.autocomplete_firewall'
),
url
(
r'^firewall/autocomplete/firewall/$'
,
'firewall_gui.views.autocomplete_firewall'
),
url
(
r'^firewall/autocomplete/domain/$'
,
'firewall_gui.views.autocomplete_domain'
),
url
(
r'^firewall/autocomplete/domain/$'
,
'firewall_gui.views.autocomplete_domain'
),
url
(
r'^firewall/autocomplete/record/$'
,
'firewall_gui.views.autocomplete_record'
),
url
(
r'^firewall/autocomplete/record/$'
,
'firewall_gui.views.autocomplete_record'
),
url
(
r'^firewall/rules/save/$'
,
'firewall_gui.views.save_rule'
),
)
)
firewall_gui/static/js/project.js
View file @
4a295ff8
...
@@ -236,6 +236,18 @@ function EntityController(url, init) {
...
@@ -236,6 +236,18 @@ function EntityController(url, init) {
$scope
.
destroyed
=
function
(
item
)
{
$scope
.
destroyed
=
function
(
item
)
{
return
!
item
.
__destroyed
;
return
!
item
.
__destroyed
;
}
}
$scope
.
save
=
function
()
{
console
.
log
(
$scope
.
entity
);
console
.
log
(
JSON
.
stringify
(
$scope
.
entity
));
$
.
ajax
({
url
:
url
+
'save/'
,
type
:
'post'
,
data
:
JSON
.
stringify
(
$scope
.
entity
),
success
:
function
(
data
)
{
console
.
log
(
data
);
}
})
}
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
$scope
.
entity
=
data
;
$scope
.
entity
=
data
;
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
].
forEach
(
function
(
t
)
{
[
'vlan'
,
'vlangroup'
,
'host'
,
'hostgroup'
,
'firewall'
].
forEach
(
function
(
t
)
{
...
...
firewall_gui/static/partials/rule-edit.html
View file @
4a295ff8
...
@@ -113,7 +113,7 @@
...
@@ -113,7 +113,7 @@
</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 (nem működik!)
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
firewall_gui/views.py
View file @
4a295ff8
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
get_object_or_404
from
django.shortcuts
import
render
,
get_object_or_404
from
django.contrib.auth.models
import
User
from
firewall.fw
import
*
from
firewall.fw
import
*
from
firewall.models
import
*
from
firewall.models
import
*
...
@@ -425,3 +426,28 @@ def autocomplete_record(request):
...
@@ -425,3 +426,28 @@ def autocomplete_record(request):
'id'
:
record
.
id
,
'id'
:
record
.
id
,
'name'
:
record
.
name
'name'
:
record
.
name
}
for
record
in
Record
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
}
for
record
in
Record
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
save_rule
(
request
):
data
=
json
.
loads
(
request
.
body
)
if
data
[
'id'
]:
rule
=
get_object_or_404
(
Rule
,
id
=
data
[
'id'
])
else
:
rule
=
Rule
.
objects
.
create
()
rule
.
direction
=
data
[
'direction'
][
'value'
]
rule
.
description
=
data
[
'description'
]
rule
.
dport
=
data
[
'dport'
]
rule
.
sport
=
data
[
'sport'
]
rule
.
proto
=
data
[
'proto'
][
'value'
]
rule
.
extra
=
data
[
'extra'
]
rule
.
accept
=
data
[
'accept'
]
rule
.
owner
=
get_object_or_404
(
User
,
username
=
data
[
'owner'
][
'name'
])
rule
.
nat
=
data
[
'nat'
]
rule
.
nat_dport
=
data
[
'nat_dport'
]
rule
.
host
=
get_object_or_404
(
Host
,
hostname
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'host'
else
None
rule
.
hostgroup
=
get_object_or_404
(
Group
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'hostgroup'
else
None
rule
.
vlan
=
get_object_or_404
(
Vlan
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'vlan'
else
None
rule
.
vlangroup
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'vlangroup'
else
None
rule
.
firewall
=
get_object_or_404
(
Firewall
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'firewall'
else
None
rule
.
foreign_network
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'foreignNetwork'
][
'name'
])
rule
.
save
()
return
HttpResponse
(
str
(
json
.
loads
(
request
.
body
)))
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