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
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):
...
@@ -1531,6 +1531,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/views/util.py
View file @
0cbec21a
...
@@ -46,6 +46,7 @@ from common.models import HumanReadableException, HumanReadableObject
...
@@ -46,6 +46,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"
)
...
@@ -169,6 +170,26 @@ class FilterMixin(object):
...
@@ -169,6 +170,26 @@ class FilterMixin(object):
return
queryset
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
):
class
CheckedDetailView
(
LoginRequiredMixin
,
DetailView
):
read_level
=
'user'
read_level
=
'user'
...
...
circle/dashboard/views/vm.py
View file @
0cbec21a
...
@@ -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
,
FilterMixin
,
GraphMixin
,
FormOperationMixin
,
VmDesc
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
,
FilterMixin
,
ListView
):
class
VmList
(
LoginRequiredMixin
,
VmDesc
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