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
6cc64519
authored
Jun 05, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: replace get_object calls with a single variable
parent
0fbdc363
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
circle/dashboard/views.py
+7
-9
No files found.
circle/dashboard/views.py
View file @
6cc64519
...
@@ -2661,20 +2661,19 @@ class ProfileView(LoginRequiredMixin, DetailView):
...
@@ -2661,20 +2661,19 @@ class ProfileView(LoginRequiredMixin, DetailView):
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ProfileView
,
self
)
.
get_context_data
(
**
kwargs
)
context
=
super
(
ProfileView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'profile'
]
=
self
.
get_object
()
user
=
self
.
get_object
()
context
[
'avatar_url'
]
=
get_user_avatar_url
(
context
[
'profile'
])
context
[
'profile'
]
=
user
context
[
'avatar_url'
]
=
get_user_avatar_url
(
user
)
context
[
'instances_owned'
]
=
Instance
.
get_objects_with_level
(
context
[
'instances_owned'
]
=
Instance
.
get_objects_with_level
(
"owner"
,
self
.
get_object
(),
disregard_superuser
=
True
"owner"
,
user
,
disregard_superuser
=
True
)
.
filter
(
destroyed_at
=
None
)
)
.
filter
(
destroyed_at
=
None
)
context
[
'instances_with_access'
]
=
Instance
.
get_objects_with_level
(
context
[
'instances_with_access'
]
=
Instance
.
get_objects_with_level
(
"user"
,
self
.
get_object
()
,
disregard_superuser
=
True
"user"
,
user
,
disregard_superuser
=
True
)
.
filter
(
destroyed_at
=
None
)
.
exclude
(
pk__in
=
context
[
'instances_owned'
])
)
.
filter
(
destroyed_at
=
None
)
.
exclude
(
pk__in
=
context
[
'instances_owned'
])
group_profiles
=
GroupProfile
.
get_objects_with_level
(
group_profiles
=
GroupProfile
.
get_objects_with_level
(
"operator"
,
self
.
request
.
user
)
"operator"
,
self
.
request
.
user
)
groups
=
Group
.
objects
.
filter
(
groupprofile__in
=
group_profiles
)
groups
=
Group
.
objects
.
filter
(
groupprofile__in
=
group_profiles
)
context
[
'groups'
]
=
self
.
get_object
()
.
groups
.
filter
(
context
[
'groups'
]
=
user
.
groups
.
filter
(
pk__in
=
groups
)
pk__in
=
groups
)
# permissions
# permissions
# show groups only if the user is superuser, or have access
# show groups only if the user is superuser, or have access
...
@@ -2686,8 +2685,7 @@ class ProfileView(LoginRequiredMixin, DetailView):
...
@@ -2686,8 +2685,7 @@ class ProfileView(LoginRequiredMixin, DetailView):
# if the logged in user is not superuser or not the user itself
# if the logged in user is not superuser or not the user itself
# filter the list so only those virtual machines are shown that are
# filter the list so only those virtual machines are shown that are
# originated from templates the logged in user is operator or higher
# originated from templates the logged in user is operator or higher
if
(
not
(
self
.
request
.
user
.
is_superuser
if
not
(
self
.
request
.
user
.
is_superuser
or
self
.
request
.
user
==
user
):
or
self
.
request
.
user
==
self
.
get_object
())):
it
=
InstanceTemplate
.
get_objects_with_level
(
"operator"
,
it
=
InstanceTemplate
.
get_objects_with_level
(
"operator"
,
self
.
request
.
user
)
self
.
request
.
user
)
context
[
'instances_owned'
]
=
context
[
'instances_owned'
]
.
filter
(
context
[
'instances_owned'
]
=
context
[
'instances_owned'
]
.
filter
(
...
...
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