Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b8cc25

Browse files
committed
Merge pull request openedx#3582 from edx/adam/some-cleaning
Adam/some cleaning
2 parents 6579364 + 3d3e15c commit 0b8cc25

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

cms/djangoapps/contentstore/views/import_export.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ def get_dir_for_fname(directory, filename):
238238

239239
# Send errors to client with stage at which error occurred.
240240
except Exception as exception: # pylint: disable=W0703
241+
log.exception(
242+
"error importing course"
243+
)
241244
return JsonResponse(
242245
{
243246
'ErrMsg': str(exception),

common/djangoapps/student/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _check_caller_authority(caller, role):
7272
:param caller: a user
7373
:param role: an AccessRole
7474
"""
75-
if not (caller.is_authenticated and caller.is_active):
75+
if not (caller.is_authenticated() and caller.is_active):
7676
raise PermissionDenied
7777
# superuser
7878
if GlobalStaff().has_user(caller):

common/djangoapps/student/tests/test_authz.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ def test_add_user_not_authenticated(self):
7676
"""
7777
Tests that adding to creator group fails if user is not authenticated
7878
"""
79-
with mock.patch.dict('django.conf.settings.FEATURES',
80-
{'DISABLE_COURSE_CREATION': False, "ENABLE_CREATOR_GROUP": True}):
79+
with mock.patch.dict(
80+
'django.conf.settings.FEATURES',
81+
{'DISABLE_COURSE_CREATION': False, "ENABLE_CREATOR_GROUP": True}
82+
):
8183
anonymous_user = AnonymousUser()
8284
role = CourseCreatorRole()
8385
add_users(self.admin, role, anonymous_user)
@@ -87,8 +89,10 @@ def test_add_user_not_active(self):
8789
"""
8890
Tests that adding to creator group fails if user is not active
8991
"""
90-
with mock.patch.dict('django.conf.settings.FEATURES',
91-
{'DISABLE_COURSE_CREATION': False, "ENABLE_CREATOR_GROUP": True}):
92+
with mock.patch.dict(
93+
'django.conf.settings.FEATURES',
94+
{'DISABLE_COURSE_CREATION': False, "ENABLE_CREATOR_GROUP": True}
95+
):
9296
self.user.is_active = False
9397
add_users(self.admin, CourseCreatorRole(), self.user)
9498
self.assertFalse(has_access(self.user, CourseCreatorRole()))
@@ -108,7 +112,7 @@ def test_add_user_to_group_requires_active(self):
108112

109113
def test_add_user_to_group_requires_authenticated(self):
110114
with self.assertRaises(PermissionDenied):
111-
self.admin.is_authenticated = False
115+
self.admin.is_authenticated = mock.Mock(return_value=False)
112116
add_users(self.admin, CourseCreatorRole(), self.user)
113117

114118
def test_remove_user_from_group_requires_staff_access(self):
@@ -123,7 +127,7 @@ def test_remove_user_from_group_requires_active(self):
123127

124128
def test_remove_user_from_group_requires_authenticated(self):
125129
with self.assertRaises(PermissionDenied):
126-
self.admin.is_authenticated = False
130+
self.admin.is_authenticated = mock.Mock(return_value=False)
127131
remove_users(self.admin, CourseCreatorRole(), self.user)
128132

129133

0 commit comments

Comments
 (0)