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
36f4de31
authored
May 07, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: autocomplete for models
parent
ac9ed756
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
cloud/urls.py
+8
-0
firewall_gui/views.py
+42
-0
No files found.
cloud/urls.py
View file @
36f4de31
...
...
@@ -105,4 +105,12 @@ urlpatterns = patterns('',
url
(
r'^firewall/blacklists/$'
,
'firewall_gui.views.list_blacklists'
),
url
(
r'^firewall/rules/(?P<id>\d+)/$'
,
'firewall_gui.views.show_rule'
),
url
(
r'^firewall/autocomplete/vlan/$'
,
'firewall_gui.views.autocomplete_vlan'
),
url
(
r'^firewall/autocomplete/vlangroup/$'
,
'firewall_gui.views.autocomplete_vlangroup'
),
url
(
r'^firewall/autocomplete/host/$'
,
'firewall_gui.views.autocomplete_host'
),
url
(
r'^firewall/autocomplete/hostgroup/$'
,
'firewall_gui.views.autocomplete_hostgroup'
),
url
(
r'^firewall/autocomplete/firewall/$'
,
'firewall_gui.views.autocomplete_firewall'
),
url
(
r'^firewall/autocomplete/domain/$'
,
'firewall_gui.views.autocomplete_domain'
),
url
(
r'^firewall/autocomplete/record/$'
,
'firewall_gui.views.autocomplete_record'
),
)
firewall_gui/views.py
View file @
36f4de31
...
...
@@ -242,3 +242,45 @@ def show_rule(request, id):
'nat_dport'
:
rule
.
nat_dport
}
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
def
autocomplete_vlan
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
vlan
.
id
,
'name'
:
vlan
.
name
}
for
vlan
in
Vlan
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_vlangroup
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
vlangroup
.
id
,
'name'
:
vlangroup
.
name
}
for
vlangroup
in
VlanGroup
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_hostgroup
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
hostgroup
.
id
,
'name'
:
hostgroup
.
name
}
for
hostgroup
in
Group
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_host
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
host
.
id
,
'name'
:
host
.
name
}
for
host
in
Host
.
objects
.
filter
(
hostname__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_firewall
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
firewall
.
id
,
'name'
:
firewall
.
name
}
for
firewall
in
Firewall
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_domain
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
domain
.
id
,
'name'
:
domain
.
name
}
for
domain
in
Domain
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
content_type
=
'application/json'
)
def
autocomplete_record
(
request
):
return
HttpResponse
(
json
.
dumps
([{
'id'
:
record
.
id
,
'name'
:
record
.
name
}
for
record
in
Record
.
objects
.
filter
(
name__icontains
=
request
.
POST
[
'name'
])[:
5
]]),
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