Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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
Hide 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):
def
json_attr
(
entity
,
attr
):
''' 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
=
{
'host'
:
'hostname'
,
'owner'
:
'username'
,}
try
:
# return something that can be converted to JSON, based on the `attr` field type
return
{
# if `attr` is an entity, parse its name&id
'ForeignKey'
:
lambda
entity
:
{
...
...
@@ -72,7 +73,7 @@ def make_entity_lister(entity_type, mapping):
if
type
(
attr
)
is
tuple
:
result
[
attr
[
0
]]
=
attr
[
1
](
entity
)
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
)
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