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
0b8cc25b
Commit
0b8cc25b
authored
May 05, 2014
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3582 from edx/adam/some-cleaning
Adam/some cleaning
parents
6579364f
3d3e15ca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
cms/djangoapps/contentstore/views/import_export.py
+3
-0
common/djangoapps/student/auth.py
+1
-1
common/djangoapps/student/tests/test_authz.py
+10
-6
No files found.
cms/djangoapps/contentstore/views/import_export.py
View file @
0b8cc25b
...
@@ -238,6 +238,9 @@ def import_handler(request, tag=None, package_id=None, branch=None, version_guid
...
@@ -238,6 +238,9 @@ def import_handler(request, tag=None, package_id=None, branch=None, version_guid
# Send errors to client with stage at which error occurred.
# Send errors to client with stage at which error occurred.
except
Exception
as
exception
:
# pylint: disable=W0703
except
Exception
as
exception
:
# pylint: disable=W0703
log
.
exception
(
"error importing course"
)
return
JsonResponse
(
return
JsonResponse
(
{
{
'ErrMsg'
:
str
(
exception
),
'ErrMsg'
:
str
(
exception
),
...
...
common/djangoapps/student/auth.py
View file @
0b8cc25b
...
@@ -72,7 +72,7 @@ def _check_caller_authority(caller, role):
...
@@ -72,7 +72,7 @@ def _check_caller_authority(caller, role):
:param caller: a user
:param caller: a user
:param role: an AccessRole
:param role: an AccessRole
"""
"""
if
not
(
caller
.
is_authenticated
and
caller
.
is_active
):
if
not
(
caller
.
is_authenticated
()
and
caller
.
is_active
):
raise
PermissionDenied
raise
PermissionDenied
# superuser
# superuser
if
GlobalStaff
()
.
has_user
(
caller
):
if
GlobalStaff
()
.
has_user
(
caller
):
...
...
common/djangoapps/student/tests/test_authz.py
View file @
0b8cc25b
...
@@ -76,8 +76,10 @@ class CreatorGroupTest(TestCase):
...
@@ -76,8 +76,10 @@ class CreatorGroupTest(TestCase):
"""
"""
Tests that adding to creator group fails if user is not authenticated
Tests that adding to creator group fails if user is not authenticated
"""
"""
with
mock
.
patch
.
dict
(
'django.conf.settings.FEATURES'
,
with
mock
.
patch
.
dict
(
{
'DISABLE_COURSE_CREATION'
:
False
,
"ENABLE_CREATOR_GROUP"
:
True
}):
'django.conf.settings.FEATURES'
,
{
'DISABLE_COURSE_CREATION'
:
False
,
"ENABLE_CREATOR_GROUP"
:
True
}
):
anonymous_user
=
AnonymousUser
()
anonymous_user
=
AnonymousUser
()
role
=
CourseCreatorRole
()
role
=
CourseCreatorRole
()
add_users
(
self
.
admin
,
role
,
anonymous_user
)
add_users
(
self
.
admin
,
role
,
anonymous_user
)
...
@@ -87,8 +89,10 @@ class CreatorGroupTest(TestCase):
...
@@ -87,8 +89,10 @@ class CreatorGroupTest(TestCase):
"""
"""
Tests that adding to creator group fails if user is not active
Tests that adding to creator group fails if user is not active
"""
"""
with
mock
.
patch
.
dict
(
'django.conf.settings.FEATURES'
,
with
mock
.
patch
.
dict
(
{
'DISABLE_COURSE_CREATION'
:
False
,
"ENABLE_CREATOR_GROUP"
:
True
}):
'django.conf.settings.FEATURES'
,
{
'DISABLE_COURSE_CREATION'
:
False
,
"ENABLE_CREATOR_GROUP"
:
True
}
):
self
.
user
.
is_active
=
False
self
.
user
.
is_active
=
False
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
self
.
assertFalse
(
has_access
(
self
.
user
,
CourseCreatorRole
()))
self
.
assertFalse
(
has_access
(
self
.
user
,
CourseCreatorRole
()))
...
@@ -108,7 +112,7 @@ class CreatorGroupTest(TestCase):
...
@@ -108,7 +112,7 @@ class CreatorGroupTest(TestCase):
def
test_add_user_to_group_requires_authenticated
(
self
):
def
test_add_user_to_group_requires_authenticated
(
self
):
with
self
.
assertRaises
(
PermissionDenied
):
with
self
.
assertRaises
(
PermissionDenied
):
self
.
admin
.
is_authenticated
=
False
self
.
admin
.
is_authenticated
=
mock
.
Mock
(
return_value
=
False
)
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
def
test_remove_user_from_group_requires_staff_access
(
self
):
def
test_remove_user_from_group_requires_staff_access
(
self
):
...
@@ -123,7 +127,7 @@ class CreatorGroupTest(TestCase):
...
@@ -123,7 +127,7 @@ class CreatorGroupTest(TestCase):
def
test_remove_user_from_group_requires_authenticated
(
self
):
def
test_remove_user_from_group_requires_authenticated
(
self
):
with
self
.
assertRaises
(
PermissionDenied
):
with
self
.
assertRaises
(
PermissionDenied
):
self
.
admin
.
is_authenticated
=
False
self
.
admin
.
is_authenticated
=
mock
.
Mock
(
return_value
=
False
)
remove_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
remove_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
...
...
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