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
13fa59a0
authored
May 29, 2014
by
Kálmán Viktor
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: filter vms
parent
f9e8b8c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
+25
-3
circle/dashboard/views.py
+25
-3
No files found.
circle/dashboard/views.py
View file @
13fa59a0
...
@@ -1102,6 +1102,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1102,6 +1102,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
'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"
,
# note: use it as ?tags[]=a,b
'owner'
:
"owner__username"
,
}
}
def
get
(
self
,
*
args
,
**
kwargs
):
def
get
(
self
,
*
args
,
**
kwargs
):
...
@@ -1130,10 +1131,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1130,10 +1131,8 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
unicode
(
self
.
request
.
user
))
unicode
(
self
.
request
.
user
))
queryset
=
Instance
.
get_objects_with_level
(
queryset
=
Instance
.
get_objects_with_level
(
'user'
,
self
.
request
.
user
)
.
filter
(
destroyed_at
=
None
)
'user'
,
self
.
request
.
user
)
.
filter
(
destroyed_at
=
None
)
s
=
self
.
request
.
GET
.
get
(
"s"
)
if
s
:
queryset
=
queryset
.
filter
(
name__icontains
=
s
)
self
.
create_fake_get_for_filter
()
sort
=
self
.
request
.
GET
.
get
(
"sort"
)
sort
=
self
.
request
.
GET
.
get
(
"sort"
)
# remove "-" that means descending order
# remove "-" that means descending order
# also check if the column name is valid
# also check if the column name is valid
...
@@ -1144,6 +1143,29 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
...
@@ -1144,6 +1143,29 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
return
queryset
.
filter
(
**
self
.
get_queryset_filters
()
return
queryset
.
filter
(
**
self
.
get_queryset_filters
()
)
.
select_related
(
'owner'
,
'node'
)
)
.
select_related
(
'owner'
,
'node'
)
def
create_fake_get_for_filter
(
self
):
s
=
self
.
request
.
GET
.
get
(
"s"
)
if
s
:
s
=
s
.
split
(
":"
)
if
len
(
s
)
<
2
:
got
=
{
'name'
:
""
.
join
(
s
)}
else
:
latest
=
s
.
pop
(
0
)
got
=
{
'
%
s'
%
latest
:
None
}
for
i
in
s
[:
-
1
]:
new
=
i
.
rsplit
(
" "
,
1
)
got
[
latest
]
=
new
[
0
]
latest
=
new
[
1
]
if
len
(
new
)
>
1
else
None
got
[
latest
]
=
s
[
-
1
]
# generate a new GET request, that is kinda fake
fake
=
self
.
request
.
GET
.
copy
()
for
k
,
v
in
got
.
iteritems
():
fake
[
"
%
s
%
s"
%
(
k
,
"[]"
if
len
(
v
.
split
(
","
))
>
1
else
""
)]
=
v
self
.
request
.
GET
=
fake
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/node-list.html"
template_name
=
"dashboard/node-list.html"
...
...
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