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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
221785a7
authored
Sep 02, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add doctest for magic method
parent
49359325
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
circle/dashboard/views.py
+15
-5
No files found.
circle/dashboard/views.py
View file @
221785a7
...
...
@@ -174,8 +174,11 @@ class FilterMixin(object):
self
)
.
get_queryset
()
.
filter
(
**
self
.
get_queryset_filters
())
def
create_fake_get
(
self
):
self
.
request
.
GET
=
self
.
_parse_get
(
self
.
request
.
GET
)
def
_parse_get
(
self
,
GET_dict
):
"""
Updates the
request's GET dict to filter the vm list
Returns a new dict from
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
...
...
@@ -185,8 +188,17 @@ class FilterMixin(object):
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}
>>> f = FilterMixin()
>>> f._parse_get({'s': "hello"})
{u'name': u'hello', s': '...'}
>>> f._parse_get({'s': "name:hello owner:test"})
{u'owner': u'test', u'name': u'hello', 's': '...'}
>>> f._parse_get({'s': "name:hello with whitespace node:node 3 oh"})
{u'node': u'node 3 oh', u'name': u'hello with whitespace', 's': '...'}
"""
s
=
self
.
request
.
GET
.
get
(
"s"
)
s
=
GET_dict
.
get
(
"s"
)
fake
=
GET_dict
.
copy
()
if
s
:
s
=
s
.
split
(
":"
)
if
len
(
s
)
<
2
:
# if there is no ':' in the string, filter by name
...
...
@@ -201,11 +213,9 @@ class FilterMixin(object):
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
[
k
]
=
v
self
.
request
.
GET
=
fake
return
fake
def
create_acl_queryset
(
self
,
model
):
cleaned_data
=
self
.
search_form
.
cleaned_data
...
...
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