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
8502093f
Commit
8502093f
authored
Mar 04, 2016
by
Michael Frey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect to otto checkout for prof ed courses if enabled
parent
40b5f8e6
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 @
8502093f
...
@@ -13,6 +13,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
...
@@ -13,6 +13,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
course_modes.tests.factories
import
CourseModeFactory
from
course_modes.tests.factories
import
CourseModeFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
import
lms.djangoapps.commerce.tests.test_utils
as
ecomm_test_utils
from
course_modes.models
import
CourseMode
,
Mode
from
course_modes.models
import
CourseMode
,
Mode
from
openedx.core.djangoapps.theming.test_util
import
with_is_edx_domain
from
openedx.core.djangoapps.theming.test_util
import
with_is_edx_domain
...
@@ -82,6 +83,25 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
...
@@ -82,6 +83,25 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
start_flow_url
=
reverse
(
'verify_student_start_flow'
,
args
=
[
unicode
(
self
.
course
.
id
)])
start_flow_url
=
reverse
(
'verify_student_start_flow'
,
args
=
[
unicode
(
self
.
course
.
id
)])
self
.
assertRedirects
(
response
,
start_flow_url
)
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
):
def
test_no_enrollment
(
self
):
# Create the course modes
# Create the course modes
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
for
mode
in
(
'audit'
,
'honor'
,
'verified'
):
...
...
common/djangoapps/course_modes/views.py
View file @
8502093f
...
@@ -80,18 +80,19 @@ class ChooseModeView(View):
...
@@ -80,18 +80,19 @@ class ChooseModeView(View):
enrollment_mode
,
is_active
=
CourseEnrollment
.
enrollment_mode_for_user
(
request
.
user
,
course_key
)
enrollment_mode
,
is_active
=
CourseEnrollment
.
enrollment_mode_for_user
(
request
.
user
,
course_key
)
modes
=
CourseMode
.
modes_for_course_dict
(
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.
# We assume that, if 'professional' is one of the modes, it should be the *only* mode.
# If we offer more modes alongside 'professional' in the future, this will need to route
# If there are both modes, default to non-id-professional.
# to the usual "choose your track" page same is true for no-id-professional mode.
has_enrolled_professional
=
(
CourseMode
.
is_professional_slug
(
enrollment_mode
)
and
is_active
)
has_enrolled_professional
=
(
CourseMode
.
is_professional_slug
(
enrollment_mode
)
and
is_active
)
if
CourseMode
.
has_professional_mode
(
modes
)
and
not
has_enrolled_professional
:
if
CourseMode
.
has_professional_mode
(
modes
)
and
not
has_enrolled_professional
:
return
redirect
(
redirect_url
=
reverse
(
'verify_student_start_flow'
,
kwargs
=
{
'course_id'
:
unicode
(
course_key
)})
reverse
(
if
ecommerce_service
.
is_enabled
(
request
):
'verify_student_start_flow'
,
professional_mode
=
modes
.
get
(
CourseMode
.
NO_ID_PROFESSIONAL_MODE
)
or
modes
.
get
(
CourseMode
.
PROFESSIONAL
)
kwargs
=
{
'course_id'
:
unicode
(
course_key
)}
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
# 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
# to do on this page. The user has almost certainly been auto-registered
...
@@ -150,7 +151,6 @@ class ChooseModeView(View):
...
@@ -150,7 +151,6 @@ class ChooseModeView(View):
context
[
"verified_description"
]
=
verified_mode
.
description
context
[
"verified_description"
]
=
verified_mode
.
description
if
verified_mode
.
sku
:
if
verified_mode
.
sku
:
ecommerce_service
=
EcommerceService
()
context
[
"use_ecommerce_payment_flow"
]
=
ecommerce_service
.
is_enabled
(
request
)
context
[
"use_ecommerce_payment_flow"
]
=
ecommerce_service
.
is_enabled
(
request
)
context
[
"ecommerce_payment_page"
]
=
ecommerce_service
.
payment_page_url
()
context
[
"ecommerce_payment_page"
]
=
ecommerce_service
.
payment_page_url
()
context
[
"sku"
]
=
verified_mode
.
sku
context
[
"sku"
]
=
verified_mode
.
sku
...
...
lms/djangoapps/commerce/tests/test_utils.py
View file @
8502093f
...
@@ -9,6 +9,14 @@ from django.test.client import RequestFactory
...
@@ -9,6 +9,14 @@ from django.test.client import RequestFactory
from
student.tests.factories
import
UserFactory
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
):
class
AuditLogTests
(
TestCase
):
"""Tests of the commerce audit logging helper."""
"""Tests of the commerce audit logging helper."""
@patch
(
'commerce.utils.log'
)
@patch
(
'commerce.utils.log'
)
...
@@ -31,10 +39,7 @@ class EcommerceServiceTests(TestCase):
...
@@ -31,10 +39,7 @@ class EcommerceServiceTests(TestCase):
self
.
user
=
UserFactory
.
create
()
self
.
user
=
UserFactory
.
create
()
self
.
request
=
self
.
request_factory
.
get
(
"foo"
)
self
.
request
=
self
.
request_factory
.
get
(
"foo"
)
self
.
request
.
user
=
self
.
user
self
.
request
.
user
=
self
.
user
CommerceConfiguration
.
objects
.
create
(
update_commerce_config
(
enabled
=
True
)
checkout_on_ecommerce_service
=
True
,
single_course_checkout_page
=
'/test_basket/'
)
super
(
EcommerceServiceTests
,
self
)
.
setUp
()
super
(
EcommerceServiceTests
,
self
)
.
setUp
()
def
test_is_enabled
(
self
):
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