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
Commit
d62e794f
authored
May 09, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: generic validation for foreign keys
parent
cf56970e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
firewall_gui/views.py
+11
-6
No files found.
firewall_gui/views.py
View file @
d62e794f
...
...
@@ -425,13 +425,18 @@ def autocomplete(request, entity):
except
Exception
as
e
:
return
HttpResponse
(
'>:-3'
,
status
=
500
)
def
get_object_or_error
(
entity
,
errors
,
**
kwargs
):
try
:
return
entity
.
objects
.
get
(
**
kwargs
)
except
:
errors
.
append
((
'
%(entity)
s with the name "
%(name)
s" does not exists!'
)
%
{
'entity'
:
getattr
(
entity
,
'__name__'
),
'name'
:
kwargs
.
values
()[
0
]})
return
None
def
set_field
(
object
,
attr
,
errors
,
**
kwargs
):
try
:
model
=
getattr
(
object
.
__class__
,
attr
)
.
field
.
rel
.
to
setattr
(
object
,
attr
,
model
.
objects
.
get
(
**
kwargs
))
except
Exception
as
e
:
errors
.
append
({
'name'
:
(
'
%(model)
s with the name "
%(name)
s" does not exists!'
)
%
{
'model'
:
model
.
__name__
,
'name'
:
kwargs
.
values
()[
0
]
}
})
def
save_rule
(
request
):
data
=
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