Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
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
53aaa57a
authored
Oct 02, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add acl data to detail view's context
parent
2532c57a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
circle/dashboard/views.py
+28
-0
No files found.
circle/dashboard/views.py
View file @
53aaa57a
from
django.core
import
signing
from
django.http
import
HttpResponse
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.generic
import
TemplateView
,
DetailView
from
django_tables2
import
SingleTableView
from
guardian.shortcuts
import
(
get_users_with_perms
,
get_groups_with_perms
,
get_perms
)
from
tables
import
VmListTable
from
vm.models
import
Instance
...
...
@@ -24,6 +29,28 @@ class IndexView(TemplateView):
return
context
def
first_common_element
(
a
,
b
):
for
i
in
a
:
if
i
in
b
:
return
i
return
None
def
get_acl_data
(
obj
):
levels
=
obj
.
_meta
.
permissions
levelids
=
[
id
for
(
id
,
name
)
in
levels
]
users
=
get_users_with_perms
(
obj
,
with_group_users
=
False
)
users
=
[{
'user'
:
u
,
'perm'
:
first_common_element
(
levelids
,
get_perms
(
u
,
obj
))}
for
u
in
users
]
groups
=
get_groups_with_perms
(
obj
)
groups
=
[{
'group'
:
g
,
'perm'
:
first_common_element
(
levelids
,
get_perms
(
g
,
obj
))}
for
g
in
groups
]
return
{
'users'
:
users
,
'groups'
:
groups
,
'levels'
:
levels
,
'url'
:
obj
.
get_absolute_url
()}
class
VmDetailView
(
DetailView
):
template_name
=
"dashboard/vm-detail.html"
queryset
=
Instance
.
objects
.
all
()
...
...
@@ -39,6 +66,7 @@ class VmDetailView(DetailView):
context
.
update
({
'vnc_url'
:
'
%
s'
%
value
})
context
[
'acl'
]
=
get_acl_data
(
instance
)
return
context
...
...
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