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
69d7abf6
authored
May 16, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: comments
parent
82514d62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
firewall_gui/views.py
+3
-2
No files found.
firewall_gui/views.py
View file @
69d7abf6
...
@@ -39,11 +39,12 @@ def map_rule_target(rule):
...
@@ -39,11 +39,12 @@ def map_rule_target(rule):
def
json_attr
(
entity
,
attr
):
def
json_attr
(
entity
,
attr
):
''' jsonify the `attr` attribute of `entity` '''
''' jsonify the `attr` attribute of `entity` '''
# an objects name usually is in the `name` attribute, but not always, so put here the exceptions
# an objects name usually is in the `name` attribute, but not always
(thanks bd!)
, so put here the exceptions
common_names
=
{
common_names
=
{
'host'
:
'hostname'
,
'host'
:
'hostname'
,
'owner'
:
'username'
,}
'owner'
:
'username'
,}
try
:
try
:
# return something that can be converted to JSON, based on the `attr` field type
return
{
return
{
# if `attr` is an entity, parse its name&id
# if `attr` is an entity, parse its name&id
'ForeignKey'
:
lambda
entity
:
{
'ForeignKey'
:
lambda
entity
:
{
...
@@ -72,7 +73,7 @@ def make_entity_lister(entity_type, mapping):
...
@@ -72,7 +73,7 @@ def make_entity_lister(entity_type, mapping):
if
type
(
attr
)
is
tuple
:
if
type
(
attr
)
is
tuple
:
result
[
attr
[
0
]]
=
attr
[
1
](
entity
)
result
[
attr
[
0
]]
=
attr
[
1
](
entity
)
else
:
else
:
# if `attr` is just a string, the try to jsonify
it
# if `attr` is just a string, the try to jsonify
the corresponding model attribute
result
[
attr
]
=
json_attr
(
entity
,
attr
)
result
[
attr
]
=
json_attr
(
entity
,
attr
)
return
result
return
result
...
...
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