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
5dcdf9a4
Commit
5dcdf9a4
authored
Mar 07, 2016
by
Michael Frey
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11755 from edx/SOL-1690
Redirect to otto checkout for prof ed courses if enabled
parents
4f5290e4
8502093f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
common/djangoapps/course_modes/tests/test_views.py
+20
-0
common/djangoapps/course_modes/views.py
+10
-10
lms/djangoapps/commerce/tests/test_utils.py
+9
-4
No files found.
common/djangoapps/course_modes/tests/test_views.py
View file @
5dcdf9a4
...
...
@@ -13,6 +13,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
course_modes.tests.factories
import
CourseModeFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
student.models
import
CourseEnrollment
import
lms.djangoapps.commerce.tests.test_utils
as
ecomm_test_utils
from
course_modes.models
import
CourseMode
,
Mode
from
openedx.core.djangoapps.theming.test_util
import
with_is_edx_domain
...
...
@@ -82,6 +83,25 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
start_flow_url
=
reverse
(
'verify_student_start_flow'
,
args
=
[
unicode
(
self
.
course
.
id
)])
self
.
assertRedirects
(
response
,
start_flow_url
)
def
test_no_id_redirect_otto
(
self
):
# Create the course modes
prof_course
=
CourseFactory
.
create
()
CourseModeFactory
(
mode_slug
=
CourseMode
.
NO_ID_PROFESSIONAL_MODE
,
course_id
=
prof_course
.
id
,
min_price
=
100
,
sku
=
'TEST'
)
ecomm_test_utils
.
update_commerce_config
(
enabled
=
True
)
# Enroll the user in the test course
CourseEnrollmentFactory
(
is_active
=
False
,
mode
=
CourseMode
.
NO_ID_PROFESSIONAL_MODE
,
course_id
=
prof_course
.
id
,
user
=
self
.
user
)
# Configure whether we're upgrading or not
url
=
reverse
(
'course_modes_choose'
,
args
=
[
unicode
(
prof_course
.
id
)])
response
=
self
.
client
.
get
(
url
)
self
.
assertRedirects
(
response
,
'http://testserver/test_basket/?sku=TEST'
,
fetch_redirect_response
=
False
)
ecomm_test_utils
.
update_commerce_config
(
enabled
=
False
)
def
test_no_enrollment
(
self
):
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
...
...
common/djangoapps/course_modes/views.py
View file @
5dcdf9a4
...
...
@@ -80,18 +80,19 @@ class ChooseModeView(View):
enrollment_mode
,
is_active
=
CourseEnrollment
.
enrollment_mode_for_user
(
request
.
user
,
course_key
)
modes
=
CourseMode
.
modes_for_course_dict
(
course_key
)
ecommerce_service
=
EcommerceService
()
# We assume that, if 'professional' is one of the modes, it is the *only* mode.
# If we offer more modes alongside 'professional' in the future, this will need to route
# to the usual "choose your track" page same is true for no-id-professional mode.
# We assume that, if 'professional' is one of the modes, it should be the *only* mode.
# If there are both modes, default to non-id-professional.
has_enrolled_professional
=
(
CourseMode
.
is_professional_slug
(
enrollment_mode
)
and
is_active
)
if
CourseMode
.
has_professional_mode
(
modes
)
and
not
has_enrolled_professional
:
return
redirect
(
reverse
(
'verify_student_start_flow'
,
kwargs
=
{
'course_id'
:
unicode
(
course_key
)}
)
)
redirect_url
=
reverse
(
'verify_student_start_flow'
,
kwargs
=
{
'course_id'
:
unicode
(
course_key
)})
if
ecommerce_service
.
is_enabled
(
request
):
professional_mode
=
modes
.
get
(
CourseMode
.
NO_ID_PROFESSIONAL_MODE
)
or
modes
.
get
(
CourseMode
.
PROFESSIONAL
)
if
professional_mode
.
sku
:
redirect_url
=
ecommerce_service
.
checkout_page_url
(
professional_mode
.
sku
)
return
redirect
(
redirect_url
)
# If there isn't a verified mode available, then there's nothing
# to do on this page. The user has almost certainly been auto-registered
...
...
@@ -150,7 +151,6 @@ class ChooseModeView(View):
context
[
"verified_description"
]
=
verified_mode
.
description
if
verified_mode
.
sku
:
ecommerce_service
=
EcommerceService
()
context
[
"use_ecommerce_payment_flow"
]
=
ecommerce_service
.
is_enabled
(
request
)
context
[
"ecommerce_payment_page"
]
=
ecommerce_service
.
payment_page_url
()
context
[
"sku"
]
=
verified_mode
.
sku
...
...
lms/djangoapps/commerce/tests/test_utils.py
View file @
5dcdf9a4
...
...
@@ -9,6 +9,14 @@ from django.test.client import RequestFactory
from
student.tests.factories
import
UserFactory
def
update_commerce_config
(
enabled
=
False
,
checkout_page
=
'/test_basket/'
):
""" Enable / Disable CommerceConfiguration model """
CommerceConfiguration
.
objects
.
create
(
checkout_on_ecommerce_service
=
enabled
,
single_course_checkout_page
=
checkout_page
)
class
AuditLogTests
(
TestCase
):
"""Tests of the commerce audit logging helper."""
@patch
(
'commerce.utils.log'
)
...
...
@@ -31,10 +39,7 @@ class EcommerceServiceTests(TestCase):
self
.
user
=
UserFactory
.
create
()
self
.
request
=
self
.
request_factory
.
get
(
"foo"
)
self
.
request
.
user
=
self
.
user
CommerceConfiguration
.
objects
.
create
(
checkout_on_ecommerce_service
=
True
,
single_course_checkout_page
=
'/test_basket/'
)
update_commerce_config
(
enabled
=
True
)
super
(
EcommerceServiceTests
,
self
)
.
setUp
()
def
test_is_enabled
(
self
):
...
...
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