Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
7b10d14f
Commit
7b10d14f
authored
Jan 28, 2015
by
muzaffaryousaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding 'user_is_staff' filed to opt_attrs in xblock user.
TNL-1185
parent
2189ef7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
common/djangoapps/xblock_django/user_service.py
+7
-4
No files found.
common/djangoapps/xblock_django/user_service.py
View file @
7b10d14f
...
...
@@ -2,12 +2,13 @@
Support for converting a django user to an XBlock user
"""
from
django.contrib.auth.models
import
User
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
xblock.reference.user_service
import
XBlockUser
,
UserService
ATTR_KEY_IS_AUTHENTICATED
=
'edx-platform.is_authenticated'
ATTR_KEY_USER_ID
=
'edx-platform.user_id'
ATTR_KEY_USERNAME
=
'edx-platform.username'
ATTR_KEY_USER_IS_STAFF
=
'edx-platform.user_is_staff'
class
DjangoXBlockUserService
(
UserService
):
...
...
@@ -17,7 +18,8 @@ class DjangoXBlockUserService(UserService):
def
__init__
(
self
,
django_user
,
**
kwargs
):
super
(
DjangoXBlockUserService
,
self
)
.
__init__
(
**
kwargs
)
self
.
_django_user
=
django_user
self
.
_user_is_staff
=
kwargs
.
get
(
'user_is_staff'
,
False
)
if
self
.
_django_user
:
self
.
_django_user
.
user_is_staff
=
kwargs
.
get
(
'user_is_staff'
,
False
)
def
get_current_user
(
self
):
"""
...
...
@@ -37,7 +39,7 @@ class DjangoXBlockUserService(UserService):
A unique anonymous_user_id for (user, course) pair.
None for Non-staff users.
"""
if
not
self
.
_user_is_staff
:
if
not
self
.
get_current_user
()
.
opt_attrs
.
get
(
ATTR_KEY_USER_IS_STAFF
)
:
return
None
# If we import these in start, it causes the contentstore library tests failed.
...
...
@@ -48,7 +50,7 @@ class DjangoXBlockUserService(UserService):
except
User
.
DoesNotExist
:
return
None
course_id
=
SlashSeparatedCourseKey
.
from_deprecated
_string
(
course_id
)
course_id
=
CourseKey
.
from
_string
(
course_id
)
return
anonymous_id_for_user
(
user
=
user
,
course_id
=
course_id
,
save
=
False
)
def
_convert_django_user_to_xblock_user
(
self
,
django_user
):
...
...
@@ -65,6 +67,7 @@ class DjangoXBlockUserService(UserService):
xblock_user
.
opt_attrs
[
ATTR_KEY_IS_AUTHENTICATED
]
=
True
xblock_user
.
opt_attrs
[
ATTR_KEY_USER_ID
]
=
django_user
.
id
xblock_user
.
opt_attrs
[
ATTR_KEY_USERNAME
]
=
django_user
.
username
xblock_user
.
opt_attrs
[
ATTR_KEY_USER_IS_STAFF
]
=
django_user
.
user_is_staff
else
:
xblock_user
.
opt_attrs
[
ATTR_KEY_IS_AUTHENTICATED
]
=
False
...
...
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