Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-poll
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
xblock-poll
Commits
ae31e802
Commit
ae31e802
authored
Jun 06, 2015
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix access control to correctly show "View results" link to staff.
parent
5aa4ec5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
poll/poll.py
+8
-9
No files found.
poll/poll.py
View file @
ae31e802
...
...
@@ -35,15 +35,13 @@ from xblockutils.publish_event import PublishEventMixin
from
xblockutils.resources
import
ResourceLoader
from
xblockutils.settings
import
XBlockWithSettingsMixin
,
ThemableXBlockMixin
HAS_EDX_ACCESS
=
False
try
:
# pylint: disable=import-error
from
django.conf
import
settings
from
courseware.access
import
has_access
from
api_manager.models
import
GroupProfile
HAS_
EDX_ACCESS
=
True
HAS_
GROUP_PROFILE
=
True
except
ImportError
:
pass
HAS_GROUP_PROFILE
=
False
class
ResourceMixin
(
XBlockWithSettingsMixin
,
ThemableXBlockMixin
):
...
...
@@ -186,21 +184,22 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
Checks to see if the user has permissions to view private results.
This only works inside the LMS.
"""
if
not
(
HAS_EDX_ACCESS
and
hasattr
(
self
.
runtime
,
'user'
)
and
hasattr
(
self
.
runtime
,
'course_id'
)
):
if
not
hasattr
(
self
.
runtime
,
'user_is_staff'
):
return
False
# Course staff users have permission to view results.
if
has_access
(
self
.
runtime
.
user
,
'staff'
,
self
,
self
.
runtime
.
course_id
)
:
if
self
.
runtime
.
user_is_staff
:
return
True
# Check if user is member of a group that is explicitly granted
# permission to view the results through django configuration.
if
not
HAS_GROUP_PROFILE
:
return
False
group_names
=
getattr
(
settings
,
'XBLOCK_POLL_EXTRA_VIEW_GROUPS'
,
[])
if
not
group_names
:
return
False
group_ids
=
self
.
runtime
.
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
user
=
self
.
runtime
.
get_real_user
(
self
.
runtime
.
anonymous_student_id
)
group_ids
=
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
return
GroupProfile
.
objects
.
filter
(
group_id__in
=
group_ids
,
name__in
=
group_names
)
.
exists
()
@staticmethod
...
...
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