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
0cbec21a
authored
Aug 16, 2016
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add VmDescFilter and 'shared with me' search choice
parent
3cff165b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
circle/dashboard/forms.py
+1
-0
circle/dashboard/views/util.py
+21
-0
circle/dashboard/views/vm.py
+2
-2
No files found.
circle/dashboard/forms.py
View file @
0cbec21a
...
...
@@ -1531,6 +1531,7 @@ class VmResourcesForm(forms.ModelForm):
vm_search_choices
=
(
(
"owned"
,
_
(
"owned"
)),
(
"shared"
,
_
(
"shared"
)),
(
"shared_with_me"
,
_
(
"shared with me"
)),
(
"all"
,
_
(
"all"
)),
)
...
...
circle/dashboard/views/util.py
View file @
0cbec21a
...
...
@@ -46,6 +46,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"
)
...
...
@@ -169,6 +170,26 @@ class FilterMixin(object):
return
queryset
class
VmDescFilterMixin
(
FilterMixin
):
def
create_acl_queryset
(
self
,
model
):
cleaned_data
=
self
.
search_form
.
cleaned_data
stype
=
cleaned_data
.
get
(
'stype'
,
'all'
)
queryset
=
super
(
VmDescFilterMixin
,
self
)
.
create_acl_queryset
(
model
)
user
=
self
.
request
.
user
if
stype
==
'owned'
:
queryset
=
queryset
.
filter
(
owner
=
user
)
elif
stype
==
'shared'
:
queryset
=
model
.
get_objects_with_level
(
'owner'
,
self
.
request
.
user
)
pk_list
=
[
record
.
pk
for
record
in
queryset
if
record
.
object_level_set
.
count
()
>
1
]
queryset
=
queryset
.
filter
(
pk__in
=
pk_list
)
elif
stype
==
'shared_with_me'
:
queryset
=
queryset
.
exclude
(
owner
=
user
)
return
queryset
class
CheckedDetailView
(
LoginRequiredMixin
,
DetailView
):
read_level
=
'user'
...
...
circle/dashboard/views/vm.py
View file @
0cbec21a
...
...
@@ -56,7 +56,7 @@ from vm.models import (
)
from
.util
import
(
CheckedDetailView
,
AjaxOperationMixin
,
OperationView
,
AclUpdateView
,
FormOperationMixin
,
FilterMixin
,
GraphMixin
,
FormOperationMixin
,
VmDesc
FilterMixin
,
GraphMixin
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
)
from
..forms
import
(
...
...
@@ -921,7 +921,7 @@ vm_mass_ops = OrderedDict([
])
class
VmList
(
LoginRequiredMixin
,
FilterMixin
,
ListView
):
class
VmList
(
LoginRequiredMixin
,
VmDesc
FilterMixin
,
ListView
):
template_name
=
"dashboard/vm-list.html"
allowed_filters
=
{
'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