Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
11bf4569
authored
Jun 05, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add comment to the create_fake_get method
parent
da7e5af8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
circle/dashboard/views.py
+15
-3
No files found.
circle/dashboard/views.py
View file @
11bf4569
...
...
@@ -1132,7 +1132,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
queryset
=
Instance
.
get_objects_with_level
(
'user'
,
self
.
request
.
user
)
.
filter
(
destroyed_at
=
None
)
self
.
create_fake_get
_for_filter
()
self
.
create_fake_get
()
sort
=
self
.
request
.
GET
.
get
(
"sort"
)
# remove "-" that means descending order
# also check if the column name is valid
...
...
@@ -1143,11 +1143,23 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
return
queryset
.
filter
(
**
self
.
get_queryset_filters
()
)
.
select_related
(
'owner'
,
'node'
)
def
create_fake_get_for_filter
(
self
):
def
create_fake_get
(
self
):
"""
Updates the request's GET dict to filter the vm list
For example: "name:xy node:1" updates the GET dict
to resemble this URL ?name=xy&node=1
"name:xy node:1".split(":") becomes ["name", "xy node", "1"]
we pop the the first element and use it as the first dict key
then we iterate over the rest of the list and split by the last
whitespace, the first part of this list will be the previous key's
value, then last part of the list will be the next key.
The final dict looks like this: {'name': xy, 'node':1}
"""
s
=
self
.
request
.
GET
.
get
(
"s"
)
if
s
:
s
=
s
.
split
(
":"
)
if
len
(
s
)
<
2
:
if
len
(
s
)
<
2
:
# if there is no ':' in the string, filter by name
got
=
{
'name'
:
s
[
0
]}
else
:
latest
=
s
.
pop
(
0
)
...
...
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