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
c11bddba
authored
Jun 13, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-fix-vm-list-filter' into 'master'
Issue Fix Vm List Filter Filtering by tags haven't worked.
parents
86d76cc1
c62287ca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
circle/dashboard/views.py
+12
-6
No files found.
circle/dashboard/views.py
View file @
c11bddba
...
@@ -128,7 +128,11 @@ class FilterMixin(object):
...
@@ -128,7 +128,11 @@ class FilterMixin(object):
filters
=
{}
filters
=
{}
for
item
in
self
.
allowed_filters
:
for
item
in
self
.
allowed_filters
:
if
item
in
self
.
request
.
GET
:
if
item
in
self
.
request
.
GET
:
filters
[
self
.
allowed_filters
[
item
]]
=
self
.
request
.
GET
[
item
]
filters
[
self
.
allowed_filters
[
item
]]
=
(
self
.
request
.
GET
[
item
]
.
split
(
","
)
if
self
.
allowed_filters
[
item
]
.
endswith
(
"__in"
)
else
self
.
request
.
GET
[
item
])
return
filters
return
filters
def
get_queryset
(
self
):
def
get_queryset
(
self
):
...
@@ -1158,7 +1162,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1158,7 +1162,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
'name'
:
"name__icontains"
,
'name'
:
"name__icontains"
,
'node'
:
"node__name__icontains"
,
'node'
:
"node__name__icontains"
,
'status'
:
"status__iexact"
,
'status'
:
"status__iexact"
,
'tags'
:
"tags__name__in"
,
# note: use it as ?tags[]=a,b
'tags[]'
:
"tags__name__in"
,
'tags'
:
"tags__name__in"
,
# for search string
'owner'
:
"owner__username"
,
'owner'
:
"owner__username"
,
}
}
...
@@ -1197,8 +1202,10 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1197,8 +1202,10 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
(
sort
[
1
:]
if
sort
[
0
]
==
"-"
else
sort
)
(
sort
[
1
:]
if
sort
[
0
]
==
"-"
else
sort
)
in
[
i
.
name
for
i
in
Instance
.
_meta
.
fields
]
+
[
"pk"
]):
in
[
i
.
name
for
i
in
Instance
.
_meta
.
fields
]
+
[
"pk"
]):
queryset
=
queryset
.
order_by
(
sort
)
queryset
=
queryset
.
order_by
(
sort
)
return
queryset
.
filter
(
**
self
.
get_queryset_filters
()
)
.
select_related
(
'owner'
,
'node'
)
return
queryset
.
filter
(
**
self
.
get_queryset_filters
())
.
select_related
(
'owner'
,
'node'
)
.
distinct
()
def
create_fake_get
(
self
):
def
create_fake_get
(
self
):
"""
"""
...
@@ -1230,8 +1237,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1230,8 +1237,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
# generate a new GET request, that is kinda fake
# generate a new GET request, that is kinda fake
fake
=
self
.
request
.
GET
.
copy
()
fake
=
self
.
request
.
GET
.
copy
()
for
k
,
v
in
got
.
iteritems
():
for
k
,
v
in
got
.
iteritems
():
fake
[
"
%
s
%
s"
%
(
fake
[
k
]
=
v
k
,
"[]"
if
len
(
v
.
split
(
","
))
>
1
else
""
)]
=
v
self
.
request
.
GET
=
fake
self
.
request
.
GET
=
fake
...
...
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