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
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
Pipeline
#241
passed with stage
in 0 seconds
Changes
3
Pipelines
1
Hide 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):
...
@@ -1541,6 +1541,7 @@ class VmResourcesForm(forms.ModelForm):
vm_search_choices
=
(
vm_search_choices
=
(
(
"owned"
,
_
(
"owned"
)),
(
"owned"
,
_
(
"owned"
)),
(
"shared"
,
_
(
"shared"
)),
(
"shared"
,
_
(
"shared"
)),
(
"shared_with_me"
,
_
(
"shared with me"
)),
(
"all"
,
_
(
"all"
)),
(
"all"
,
_
(
"all"
)),
)
)
...
...
circle/dashboard/templates/dashboard/vm-list.html
View file @
c177b3e8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
{% trans "Sorting ... " %}
{% trans "Sorting ... " %}
<!--<i class="fa fa-refresh fa-spin fa-2x"></i>-->
<!--<i class="fa fa-refresh fa-spin fa-2x"></i>-->
</div>
</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>
<h3
class=
"no-margin"
><i
class=
"fa fa-desktop"
></i>
{% trans "Virtual machines" %}
</h3>
</div>
</div>
<div
class=
"panel-body"
>
<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
...
@@ -32,7 +32,7 @@ from django.contrib.sites.shortcuts import get_current_site
from
django.core
import
signing
from
django.core
import
signing
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.exceptions
import
PermissionDenied
,
SuspiciousOperation
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.db.models
import
Q
from
django.db.models
import
Q
,
Count
,
Sum
from
django.http
import
(
from
django.http
import
(
HttpResponse
,
Http404
,
HttpResponseRedirect
,
JsonResponse
HttpResponse
,
Http404
,
HttpResponseRedirect
,
JsonResponse
)
)
...
@@ -55,6 +55,7 @@ from common.models import HumanReadableException, HumanReadableObject
...
@@ -55,6 +55,7 @@ from common.models import HumanReadableException, HumanReadableObject
from
..models
import
GroupProfile
,
Profile
from
..models
import
GroupProfile
,
Profile
from
..forms
import
TransferOwnershipForm
from
..forms
import
TransferOwnershipForm
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
@@ -167,14 +168,31 @@ class FilterMixin(object):
...
@@ -167,14 +168,31 @@ class FilterMixin(object):
def
create_acl_queryset
(
self
,
model
):
def
create_acl_queryset
(
self
,
model
):
cleaned_data
=
self
.
search_form
.
cleaned_data
cleaned_data
=
self
.
search_form
.
cleaned_data
stype
=
cleaned_data
.
get
(
'stype'
,
"all"
)
stype
=
cleaned_data
.
get
(
'stype'
,
'all'
)
superuser
=
stype
==
"all"
superuser
=
stype
==
'all'
shared
=
stype
==
"shared"
or
stype
==
"all"
shared
=
stype
==
'shared'
or
stype
==
'all'
level
=
"owner"
if
stype
==
"owned"
else
"user"
level
=
'owner'
if
stype
==
'owned'
else
'user'
user
=
self
.
request
.
user
queryset
=
model
.
get_objects_with_level
(
queryset
=
model
.
get_objects_with_level
(
level
,
self
.
request
.
user
,
level
,
user
,
group_also
=
shared
,
disregard_superuser
=
not
superuser
)
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
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