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
5a1df635
Commit
5a1df635
authored
Oct 27, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5735 from edx/will/update-release-10-27
Merge release into master (with changes from Friday 10/24/14)
parents
25a74552
0cac6ea2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
common/djangoapps/student/tests/test_enrollment.py
+23
-3
common/djangoapps/third_party_auth/pipeline.py
+10
-9
No files found.
common/djangoapps/student/tests/test_enrollment.py
View file @
5a1df635
...
@@ -110,12 +110,32 @@ class EnrollmentTest(ModuleStoreTestCase):
...
@@ -110,12 +110,32 @@ class EnrollmentTest(ModuleStoreTestCase):
self
.
client
.
logout
()
self
.
client
.
logout
()
self
.
client
.
get
(
reverse
(
'register_user'
),
{
'course_id'
:
self
.
course
.
id
})
self
.
client
.
get
(
reverse
(
'register_user'
),
{
'course_id'
:
self
.
course
.
id
})
self
.
client
.
login
(
username
=
self
.
USERNAME
,
password
=
self
.
PASSWORD
)
self
.
client
.
login
(
username
=
self
.
USERNAME
,
password
=
self
.
PASSWORD
)
self
.
dummy_request
=
RequestFactory
()
.
request
()
dummy_request
=
RequestFactory
()
.
request
()
self
.
dummy_request
.
session
=
self
.
client
.
session
dummy_request
.
session
=
self
.
client
.
session
strategy
=
DjangoStrategy
(
RequestFactory
,
request
=
self
.
dummy_request
)
strategy
=
DjangoStrategy
(
RequestFactory
,
request
=
dummy_request
)
change_enrollment_third_party
(
is_register
=
True
,
strategy
=
strategy
,
user
=
self
.
user
)
change_enrollment_third_party
(
is_register
=
True
,
strategy
=
strategy
,
user
=
self
.
user
)
self
.
assertTrue
(
CourseEnrollment
.
is_enrolled
(
self
.
user
,
self
.
course
.
id
))
self
.
assertTrue
(
CourseEnrollment
.
is_enrolled
(
self
.
user
,
self
.
course
.
id
))
def
test_no_prof_ed_third_party_autoenroll
(
self
):
"""
Test that a user authenticating via third party auth while attempting to enroll
in a professional education course is not automatically enrolled in the course.
"""
self
.
client
.
logout
()
# Create the course mode required for this test case
CourseModeFactory
(
course_id
=
self
.
course
.
id
,
mode_slug
=
'professional'
)
self
.
client
.
get
(
reverse
(
'register_user'
),
{
'course_id'
:
self
.
course
.
id
})
self
.
client
.
login
(
username
=
self
.
USERNAME
,
password
=
self
.
PASSWORD
)
dummy_request
=
RequestFactory
()
.
request
()
dummy_request
.
session
=
self
.
client
.
session
strategy
=
DjangoStrategy
(
RequestFactory
,
request
=
dummy_request
)
change_enrollment_third_party
(
is_register
=
True
,
strategy
=
strategy
,
user
=
self
.
user
)
# Verify that the user has not been enrolled in the course
self
.
assertFalse
(
CourseEnrollment
.
is_enrolled
(
self
.
user
,
self
.
course
.
id
))
def
test_unenroll
(
self
):
def
test_unenroll
(
self
):
# Enroll the student in the course
# Enroll the student in the course
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
id
,
mode
=
"honor"
)
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
id
,
mode
=
"honor"
)
...
...
common/djangoapps/third_party_auth/pipeline.py
View file @
5a1df635
...
@@ -69,8 +69,8 @@ from social.apps.django_app.default import models
...
@@ -69,8 +69,8 @@ from social.apps.django_app.default import models
from
social.exceptions
import
AuthException
from
social.exceptions
import
AuthException
from
social.pipeline
import
partial
from
social.pipeline
import
partial
from
student.models
import
CourseEnrollment
,
CourseEnrollmentException
from
student.models
import
Course
Mode
,
Course
Enrollment
,
CourseEnrollmentException
from
opaque_keys.edx.
locations
import
SlashSeparated
CourseKey
from
opaque_keys.edx.
keys
import
CourseKey
from
logging
import
getLogger
from
logging
import
getLogger
...
@@ -420,14 +420,15 @@ def change_enrollment(*args, **kwargs):
...
@@ -420,14 +420,15 @@ def change_enrollment(*args, **kwargs):
a course, we automatically log them into that course.
a course, we automatically log them into that course.
"""
"""
if
kwargs
[
'strategy'
]
.
session_get
(
'registration_course_id'
):
if
kwargs
[
'strategy'
]
.
session_get
(
'registration_course_id'
):
try
:
course_id
=
CourseKey
.
from_string
(
CourseEnrollment
.
enroll
(
kwargs
[
'user'
],
SlashSeparatedCourseKey
.
from_deprecated_string
(
kwargs
[
'strategy'
]
.
session_get
(
'registration_course_id'
)
kwargs
[
'strategy'
]
.
session_get
(
'registration_course_id'
)
)
)
)
available_modes
=
CourseMode
.
modes_for_course_dict
(
course_id
)
if
'honor'
in
available_modes
:
try
:
CourseEnrollment
.
enroll
(
kwargs
[
'user'
],
course_id
)
except
CourseEnrollmentException
:
except
CourseEnrollmentException
:
pass
pass
except
Exception
,
e
:
except
Exception
as
ex
:
logger
.
exception
(
e
)
logger
.
exception
(
ex
)
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