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
f37d6bc9
authored
May 22, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: provide default values for new Rule objects
parent
90a22a2f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
52 deletions
+81
-52
firewall_gui/views.py
+81
-52
No files found.
firewall_gui/views.py
View file @
f37d6bc9
...
@@ -168,58 +168,87 @@ def list_entities(request, name):
...
@@ -168,58 +168,87 @@ def list_entities(request, name):
}[
name
](
request
)),
content_type
=
'application/json'
)
}[
name
](
request
)),
content_type
=
'application/json'
)
def
show_rule
(
request
,
id
):
def
show_rule
(
request
,
id
=
None
):
rule
=
get_object_or_404
(
Rule
,
id
=
id
)
try
:
rule
=
{
rule
=
Rule
.
objects
.
get
(
id
=
id
)
'id'
:
rule
.
id
,
rule
=
{
'target'
:
{
'id'
:
rule
.
id
,
'name'
:
rule
.
vlan
.
name
,
'target'
:
{
'id'
:
rule
.
vlan
.
id
,
'name'
:
rule
.
vlan
.
name
,
'type'
:
'vlan'
,
'id'
:
rule
.
vlan
.
id
,
}
if
rule
.
vlan
else
{
'type'
:
'vlan'
,
'name'
:
rule
.
vlangroup
.
name
,
}
if
rule
.
vlan
else
{
'id'
:
rule
.
vlangroup
.
id
,
'name'
:
rule
.
vlangroup
.
name
,
'type'
:
'vlangroup'
,
'id'
:
rule
.
vlangroup
.
id
,
}
if
rule
.
vlangroup
else
{
'type'
:
'vlangroup'
,
'name'
:
rule
.
hostgroup
.
name
,
}
if
rule
.
vlangroup
else
{
'id'
:
rule
.
hostgroup
.
id
,
'name'
:
rule
.
hostgroup
.
name
,
'type'
:
'hostgroup'
,
'id'
:
rule
.
hostgroup
.
id
,
}
if
rule
.
hostgroup
else
{
'type'
:
'hostgroup'
,
'name'
:
rule
.
firewall
.
name
,
}
if
rule
.
hostgroup
else
{
'id'
:
rule
.
firewall
.
id
,
'name'
:
rule
.
firewall
.
name
,
'type'
:
'firewall'
,
'id'
:
rule
.
firewall
.
id
,
}
if
rule
.
firewall
else
{
'type'
:
'firewall'
,
'name'
:
rule
.
host
.
hostname
,
}
if
rule
.
firewall
else
{
'id'
:
rule
.
host
.
id
,
'name'
:
rule
.
host
.
hostname
,
'type'
:
'host'
,
'id'
:
rule
.
host
.
id
,
},
'type'
:
'host'
,
'type'
:
rule
.
r_type
,
},
'direction'
:
{
'type'
:
rule
.
r_type
,
'value'
:
rule
.
direction
,
'direction'
:
{
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'direction'
)[
0
]
.
choices
,
'value'
:
rule
.
direction
,
},
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'direction'
)[
0
]
.
choices
,
'proto'
:
{
},
'value'
:
rule
.
proto
,
'proto'
:
{
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'proto'
)[
0
]
.
choices
,
'value'
:
rule
.
proto
,
},
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'proto'
)[
0
]
.
choices
,
'owner'
:
{
},
'name'
:
str
(
rule
.
owner
),
'owner'
:
{
'id'
:
rule
.
owner
.
id
'name'
:
str
(
rule
.
owner
),
},
'id'
:
rule
.
owner
.
id
'foreignNetwork'
:
{
},
'name'
:
rule
.
foreign_network
.
name
,
'foreignNetwork'
:
{
'id'
:
rule
.
foreign_network
.
id
,
'name'
:
rule
.
foreign_network
.
name
,
},
'id'
:
rule
.
foreign_network
.
id
,
'created_at'
:
rule
.
created_at
.
isoformat
(),
},
'modified_at'
:
rule
.
modified_at
.
isoformat
(),
'created_at'
:
rule
.
created_at
.
isoformat
(),
'nat'
:
rule
.
nat
,
'modified_at'
:
rule
.
modified_at
.
isoformat
(),
'accept'
:
rule
.
accept
,
'nat'
:
rule
.
nat
,
'description'
:
rule
.
description
,
'accept'
:
rule
.
accept
,
'dport'
:
rule
.
dport
,
'description'
:
rule
.
description
,
'sport'
:
rule
.
sport
,
'dport'
:
rule
.
dport
,
'extra'
:
rule
.
extra
,
'sport'
:
rule
.
sport
,
'nat_dport'
:
rule
.
nat_dport
'extra'
:
rule
.
extra
,
}
'nat_dport'
:
rule
.
nat_dport
}
except
:
rule
=
{
'id'
:
None
,
'target'
:
{
'id'
:
None
,
'name'
:
None
,
'type'
:
None
},
'type'
:
None
,
'direction'
:
{
'value'
:
None
,
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'direction'
)[
0
]
.
choices
,
},
'proto'
:
{
'value'
:
None
,
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'proto'
)[
0
]
.
choices
,
},
'owner'
:
{
'id'
:
None
,
'name'
:
None
,
},
'foreignNetwork'
:
{
'name'
:
None
,
'id'
:
None
},
'created_at'
:
None
,
'modified_at'
:
None
,
'nat'
:
False
,
'accept'
:
False
,
'description'
:
''
,
'dport'
:
None
,
'sport'
:
None
,
'extra'
:
''
,
'nat_dport'
:
None
,
}
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
rule
),
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