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
c0b50c7f
Commit
c0b50c7f
authored
Mar 26, 2014
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change user.is_authenticated to user.is_authenticated() in roles.py.
LMS-2442
parent
c73ac2af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
common/djangoapps/student/roles.py
+3
-3
common/djangoapps/student/tests/test_authz.py
+5
-4
common/djangoapps/student/tests/test_email.py
+4
-3
common/djangoapps/student/views.py
+1
-1
No files found.
common/djangoapps/student/roles.py
View file @
c0b50c7f
...
...
@@ -64,7 +64,7 @@ class GlobalStaff(AccessRole):
def
add_users
(
self
,
*
users
):
for
user
in
users
:
if
(
user
.
is_authenticated
and
user
.
is_active
):
if
(
user
.
is_authenticated
()
and
user
.
is_active
):
user
.
is_staff
=
True
user
.
save
()
...
...
@@ -98,7 +98,7 @@ class GroupBasedRole(AccessRole):
"""
Return whether the supplied django user has access to this role.
"""
if
not
(
user
.
is_authenticated
and
user
.
is_active
):
if
not
(
user
.
is_authenticated
()
and
user
.
is_active
):
return
False
# pylint: disable=protected-access
...
...
@@ -113,7 +113,7 @@ class GroupBasedRole(AccessRole):
"""
# silently ignores anonymous and inactive users so that any that are
# legit get updated.
users
=
[
user
for
user
in
users
if
user
.
is_authenticated
and
user
.
is_active
]
users
=
[
user
for
user
in
users
if
user
.
is_authenticated
()
and
user
.
is_active
]
group
,
_
=
Group
.
objects
.
get_or_create
(
name
=
self
.
_group_names
[
0
])
group
.
user_set
.
add
(
*
users
)
# remove cache
...
...
common/djangoapps/student/tests/test_authz.py
View file @
c0b50c7f
...
...
@@ -4,7 +4,7 @@ Tests authz.py
import
mock
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
xmodule.modulestore
import
Location
from
django.core.exceptions
import
PermissionDenied
...
...
@@ -78,9 +78,10 @@ class CreatorGroupTest(TestCase):
"""
with
mock
.
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_COURSE_CREATION'
:
False
,
"ENABLE_CREATOR_GROUP"
:
True
}):
self
.
user
.
is_authenticated
=
False
add_users
(
self
.
admin
,
CourseCreatorRole
(),
self
.
user
)
self
.
assertFalse
(
has_access
(
self
.
user
,
CourseCreatorRole
()))
anonymous_user
=
AnonymousUser
()
role
=
CourseCreatorRole
()
add_users
(
self
.
admin
,
role
,
anonymous_user
)
self
.
assertFalse
(
has_access
(
anonymous_user
,
role
))
def
test_add_user_not_active
(
self
):
"""
...
...
common/djangoapps/student/tests/test_email.py
View file @
c0b50c7f
...
...
@@ -5,7 +5,7 @@ import unittest
from
student.tests.factories
import
UserFactory
,
RegistrationFactory
,
PendingEmailChangeFactory
from
student.views
import
reactivation_email_for_user
,
change_email_request
,
confirm_email_change
from
student.models
import
UserProfile
,
PendingEmailChange
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.test
import
TestCase
,
TransactionTestCase
from
django.test.client
import
RequestFactory
from
mock
import
Mock
,
patch
...
...
@@ -157,10 +157,11 @@ class EmailChangeRequestTests(TestCase):
self
.
assertFalse
(
self
.
user
.
email_user
.
called
)
def
test_unauthenticated
(
self
):
self
.
user
.
is_authenticated
=
False
self
.
request
.
user
=
AnonymousUser
()
self
.
request
.
user
.
email_user
=
Mock
()
with
self
.
assertRaises
(
Http404
):
change_email_request
(
self
.
request
)
self
.
assertFalse
(
self
.
user
.
email_user
.
called
)
self
.
assertFalse
(
self
.
request
.
user
.
email_user
.
called
)
def
test_invalid_password
(
self
):
self
.
request
.
POST
[
'password'
]
=
'wrong'
...
...
common/djangoapps/student/views.py
View file @
c0b50c7f
...
...
@@ -1522,7 +1522,7 @@ def change_email_request(request):
""" AJAX call from the profile page. User wants a new e-mail.
"""
## Make sure it checks for existing e-mail conflicts
if
not
request
.
user
.
is_authenticated
:
if
not
request
.
user
.
is_authenticated
()
:
raise
Http404
user
=
request
.
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