Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c177b3e8
authored
Oct 05, 2016
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_458' into 'master'
Rework VM list filter More info: #458 See merge request !387
parents
11e13c2e
ca15148f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
8 deletions
+28
-8
circle/dashboard/forms.py
+1
-0
circle/dashboard/templates/dashboard/vm-list.html
+1
-0
circle/dashboard/views/util.py
+26
-8
No files found.
circle/dashboard/forms.py
View file @
c177b3e8
...
...
@@ -1541,6 +1541,7 @@ class VmResourcesForm(forms.ModelForm):
vm_search_choices
=
(
(
"owned"
,
_
(
"owned"
)),
(
"shared"
,
_
(
"shared"
)),
(
"shared_with_me"
,
_
(
"shared with me"
)),
(
"all"
,
_
(
"all"
)),
)
...
...
circle/dashboard/templates/dashboard/vm-list.html
View file @
c177b3e8
...
...
@@ -14,6 +14,7 @@
{% trans "Sorting ... " %}
<!--<i class="fa fa-refresh fa-spin fa-2x"></i>-->
</div>
<a
class=
"pull-right btn btn-success btn-xs vm-create"
href=
"{% url "
dashboard
.
views
.
vm-create
"
%}"
><i
class=
"fa fa-plus-circle"
></i>
{% trans "new virtual machine" %}
</a>
<h3
class=
"no-margin"
><i
class=
"fa fa-desktop"
></i>
{% trans "Virtual machines" %}
</h3>
</div>
<div
class=
"panel-body"
>
...
...
circle/dashboard/views/util.py
View file @
c177b3e8
...
...
@@ -32,7 +32,7 @@ from django.contrib.sites.shortcuts import get_current_site
from
django.core
import
signing
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
Q
from
django.db.models
import
Q
,
Count
,
Sum
from
django.http
import
(
HttpResponse
,
Http404
,
HttpResponseRedirect
,
JsonResponse
)
...
...
@@ -55,6 +55,7 @@ from common.models import HumanReadableException, HumanReadableObject
from
..models
import
GroupProfile
,
Profile
from
..forms
import
TransferOwnershipForm
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
...
@@ -167,14 +168,31 @@ class FilterMixin(object):
def
create_acl_queryset
(
self
,
model
):
cleaned_data
=
self
.
search_form
.
cleaned_data
stype
=
cleaned_data
.
get
(
'stype'
,
"all"
)
superuser
=
stype
==
"all"
shared
=
stype
==
"shared"
or
stype
==
"all"
level
=
"owner"
if
stype
==
"owned"
else
"user"
stype
=
cleaned_data
.
get
(
'stype'
,
'all'
)
superuser
=
stype
==
'all'
shared
=
stype
==
'shared'
or
stype
==
'all'
level
=
'owner'
if
stype
==
'owned'
else
'user'
user
=
self
.
request
.
user
queryset
=
model
.
get_objects_with_level
(
level
,
self
.
request
.
user
,
group_also
=
shared
,
disregard_superuser
=
not
superuser
,
)
level
,
user
,
group_also
=
shared
,
disregard_superuser
=
not
superuser
)
if
stype
==
'owned'
:
queryset
=
queryset
.
filter
(
owner
=
user
)
elif
stype
==
'shared'
:
queryset
=
queryset
.
filter
(
owner
=
user
)
pk_list
=
[]
for
record
in
queryset
:
count
=
record
.
object_level_set
.
annotate
(
Count
(
'users'
),
Count
(
'groups'
))
.
aggregate
(
Sum
(
'users__count'
),
Sum
(
'groups__count'
))
if
(
count
[
'users__count__sum'
]
>
1
or
count
[
'groups__count__sum'
]
>
0
):
pk_list
.
append
(
record
.
pk
)
queryset
=
queryset
.
filter
(
pk__in
=
pk_list
)
elif
stype
==
'shared_with_me'
:
queryset
=
queryset
.
exclude
(
owner
=
user
)
return
queryset
...
...
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