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
c85ab08b
authored
Apr 23, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: json response for rules/list
parent
bdd52a80
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
7 deletions
+47
-7
firewall_gui/templates/base2.html
+10
-2
firewall_gui/views.py
+37
-5
No files found.
firewall_gui/templates/base2.html
View file @
c85ab08b
...
@@ -72,8 +72,16 @@
...
@@ -72,8 +72,16 @@
<script
src=
"{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}js/bootstrap.min.js"
></script>
<script
src=
"{% templatetag openvariable %} STATIC_URL {% templatetag closevariable %}js/bootstrap.min.js"
></script>
<!-- place project specific Javascript in this file -->
<!-- place project specific Javascript in this file -->
<script
src=
"{% static "
js
/
project
.
js
"
%}"
>
</script>
<script
src=
"{% static "
js
/
project
.
js
"
%}"
>
{% block extra_js %} {% endblock %}
{
%
block
extra_js
%
}
$
(
function
()
{
console
.
log
(
'foo);'
)
$
.
get
(
'/firewall/rules/list'
,
function
(
data
)
{
console
.
log
(
data
);
});
})
{
%
endblock
%
}
</script>
</body>
</body>
</html>
</html>
firewall_gui/views.py
View file @
c85ab08b
...
@@ -5,11 +5,43 @@ from firewall.fw import *
...
@@ -5,11 +5,43 @@ from firewall.fw import *
from
firewall.models
import
*
from
firewall.models
import
*
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"Ez itt a bd tuzfaladminja."
)
return
render
(
request
,
'base2.html'
)
def
list_rules
(
request
):
def
list_rules
(
request
):
rules
=
Rule
.
objects
.
all
()
rules
=
[{
return
render
(
request
,
'rule/list.html'
,
{
'id'
:
rule
.
id
,
'rules'
:
rules
,
'vlan'
:
{
})
'name'
:
rule
.
vlan
.
name
,
'id'
:
rule
.
vlan
.
id
,
}
if
rule
.
vlan
else
None
,
'vlangroup'
:
{
'name'
:
rule
.
vlangroup
.
name
,
'id'
:
rule
.
vlangroup
.
id
,
}
if
rule
.
vlangroup
else
None
,
'hostgroup'
:
{
'name'
:
rule
.
hostgroup
.
name
,
'id'
:
rule
.
hostgroup
.
id
,
}
if
rule
.
hostgroup
else
None
,
'firewall'
:
{
'name'
:
rule
.
firewall
.
name
,
'id'
:
rule
.
firewall
.
id
,
}
if
rule
.
firewall
else
None
,
'host'
:
{
'name'
:
rule
.
host
.
hostname
,
'id'
:
rule
.
host
.
id
,
}
if
rule
.
host
else
None
,
'type'
:
rule
.
r_type
,
'direction'
:
rule
.
get_direction_display
(),
'proto'
:
rule
.
proto
,
'owner'
:
{
'name'
:
str
(
rule
.
owner
),
'id'
:
rule
.
owner
.
id
},
'created_at'
:
rule
.
created_at
.
isoformat
(),
'modified_at'
:
rule
.
modified_at
.
isoformat
(),
'nat'
:
rule
.
nat
,
'accept'
:
rule
.
accept
,
'description'
:
rule
.
description
,
}
for
rule
in
Rule
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
rules
,
indent
=
2
),
content_type
=
"application/json"
)
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