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
749d0686
authored
Aug 16, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: move VmDescFilterMixin into FilterMixin and rewrite query for 'shared' stype
parent
4c5d09d7
Pipeline
#176
passed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
23 deletions
+20
-23
circle/dashboard/views/util.py
+18
-21
circle/dashboard/views/vm.py
+2
-2
No files found.
circle/dashboard/views/util.py
View file @
749d0686
...
@@ -29,7 +29,7 @@ from django.core.exceptions import PermissionDenied, SuspiciousOperation
...
@@ -29,7 +29,7 @@ from django.core.exceptions import PermissionDenied, SuspiciousOperation
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.auth.views
import
redirect_to_login
from
django.contrib.auth.views
import
redirect_to_login
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
)
)
...
@@ -159,31 +159,28 @@ class FilterMixin(object):
...
@@ -159,31 +159,28 @@ 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"
)
superuser
=
stype
==
"all"
shared
=
stype
==
"shared"
or
stype
==
"all"
level
=
"owner"
if
stype
==
"owned"
else
"user"
queryset
=
model
.
get_objects_with_level
(
level
,
self
.
request
.
user
,
group_also
=
shared
,
disregard_superuser
=
not
superuser
,
)
return
queryset
class
VmDescFilterMixin
(
FilterMixin
):
def
create_acl_queryset
(
self
,
model
):
cleaned_data
=
self
.
search_form
.
cleaned_data
stype
=
cleaned_data
.
get
(
'stype'
,
'all'
)
stype
=
cleaned_data
.
get
(
'stype'
,
'all'
)
queryset
=
super
(
VmDescFilterMixin
,
self
)
.
create_acl_queryset
(
model
)
superuser
=
stype
==
'all'
shared
=
stype
==
'shared'
or
stype
==
'all'
level
=
'owner'
if
stype
==
'owned'
else
'user'
user
=
self
.
request
.
user
user
=
self
.
request
.
user
queryset
=
model
.
get_objects_with_level
(
level
,
user
,
group_also
=
shared
,
disregard_superuser
=
not
superuser
)
if
stype
==
'owned'
:
if
stype
==
'owned'
:
queryset
=
queryset
.
filter
(
owner
=
user
)
queryset
=
queryset
.
filter
(
owner
=
user
)
elif
stype
==
'shared'
:
elif
stype
==
'shared'
:
queryset
=
model
.
get_objects_with_level
(
queryset
=
queryset
.
filter
(
owner
=
user
)
'owner'
,
self
.
request
.
user
)
pk_list
=
[
record
.
pk
for
record
in
queryset
pk_list
=
[]
if
record
.
object_level_set
.
count
()
>
1
]
for
record
in
queryset
:
sum
=
record
.
object_level_set
.
annotate
(
Count
(
'users'
),
Count
(
'groups'
))
.
aggregate
(
Sum
(
'users__count'
),
Sum
(
'groups__count'
))
if
(
sum
[
'users__count__sum'
]
>
1
or
sum
[
'groups__count__sum'
]
>
0
):
pk_list
.
append
(
record
.
pk
)
queryset
=
queryset
.
filter
(
pk__in
=
pk_list
)
queryset
=
queryset
.
filter
(
pk__in
=
pk_list
)
elif
stype
==
'shared_with_me'
:
elif
stype
==
'shared_with_me'
:
queryset
=
queryset
.
exclude
(
owner
=
user
)
queryset
=
queryset
.
exclude
(
owner
=
user
)
...
...
circle/dashboard/views/vm.py
View file @
749d0686
...
@@ -56,7 +56,7 @@ from vm.models import (
...
@@ -56,7 +56,7 @@ from vm.models import (
)
)
from
.util
import
(
from
.util
import
(
CheckedDetailView
,
AjaxOperationMixin
,
OperationView
,
AclUpdateView
,
CheckedDetailView
,
AjaxOperationMixin
,
OperationView
,
AclUpdateView
,
FormOperationMixin
,
VmDesc
FilterMixin
,
GraphMixin
,
FormOperationMixin
,
FilterMixin
,
GraphMixin
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
)
)
from
..forms
import
(
from
..forms
import
(
...
@@ -921,7 +921,7 @@ vm_mass_ops = OrderedDict([
...
@@ -921,7 +921,7 @@ vm_mass_ops = OrderedDict([
])
])
class
VmList
(
LoginRequiredMixin
,
VmDesc
FilterMixin
,
ListView
):
class
VmList
(
LoginRequiredMixin
,
FilterMixin
,
ListView
):
template_name
=
"dashboard/vm-list.html"
template_name
=
"dashboard/vm-list.html"
allowed_filters
=
{
allowed_filters
=
{
'name'
:
"name__icontains"
,
'name'
:
"name__icontains"
,
...
...
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