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
c68426c3
Commit
c68426c3
authored
Dec 24, 2014
by
Will Daly
Committed by
Will Daly
Dec 29, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect from old receipt page
parent
d97bf059
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
2 deletions
+81
-2
lms/djangoapps/shoppingcart/tests/test_views.py
+64
-2
lms/djangoapps/shoppingcart/views.py
+17
-0
No files found.
lms/djangoapps/shoppingcart/tests/test_views.py
View file @
c68426c3
...
@@ -3,6 +3,8 @@ Tests for Shopping Cart views
...
@@ -3,6 +3,8 @@ Tests for Shopping Cart views
"""
"""
import
pytz
import
pytz
from
urlparse
import
urlparse
from
urlparse
import
urlparse
from
decimal
import
Decimal
import
json
from
django.http
import
HttpRequest
from
django.http
import
HttpRequest
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -27,6 +29,8 @@ from xmodule.modulestore.tests.django_utils import (
...
@@ -27,6 +29,8 @@ from xmodule.modulestore.tests.django_utils import (
)
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
util.date_utils
import
get_default_time_display
from
util.date_utils
import
get_default_time_display
from
util.testing
import
UrlResetMixin
from
shoppingcart.views
import
_can_download_report
,
_get_date_from_str
from
shoppingcart.views
import
_can_download_report
,
_get_date_from_str
from
shoppingcart.models
import
(
from
shoppingcart.models
import
(
Order
,
CertificateItem
,
PaidCourseRegistration
,
CourseRegCodeItem
,
Order
,
CertificateItem
,
PaidCourseRegistration
,
CourseRegCodeItem
,
...
@@ -42,8 +46,6 @@ from shoppingcart.processors import render_purchase_form_html
...
@@ -42,8 +46,6 @@ from shoppingcart.processors import render_purchase_form_html
from
shoppingcart.admin
import
SoftDeleteCouponAdmin
from
shoppingcart.admin
import
SoftDeleteCouponAdmin
from
shoppingcart.views
import
initialize_report
from
shoppingcart.views
import
initialize_report
from
shoppingcart.tests.payment_fake
import
PaymentFakeView
from
shoppingcart.tests.payment_fake
import
PaymentFakeView
from
decimal
import
Decimal
import
json
def
mock_render_purchase_form_html
(
*
args
,
**
kwargs
):
def
mock_render_purchase_form_html
(
*
args
,
**
kwargs
):
...
@@ -1231,6 +1233,66 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
...
@@ -1231,6 +1233,66 @@ class ShoppingCartViewsTests(ModuleStoreTestCase):
self
.
_assert_404
(
reverse
(
'shoppingcart.views.register_courses'
,
args
=
[]))
self
.
_assert_404
(
reverse
(
'shoppingcart.views.register_courses'
,
args
=
[]))
# TODO (ECOM-188): Once we complete the A/B test of separate
# verified/payment flows, we can replace these tests
# with something more general.
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
class
ReceiptRedirectTest
(
UrlResetMixin
,
ModuleStoreTestCase
):
"""Test special-case redirect from the receipt page. """
COST
=
40
PASSWORD
=
'password'
@patch.dict
(
settings
.
FEATURES
,
{
'SEPARATE_VERIFICATION_FROM_PAYMENT'
:
True
})
def
setUp
(
self
):
super
(
ReceiptRedirectTest
,
self
)
.
setUp
(
'verify_student.urls'
)
self
.
user
=
UserFactory
.
create
()
self
.
user
.
set_password
(
self
.
PASSWORD
)
self
.
user
.
save
()
self
.
course
=
CourseFactory
.
create
()
self
.
course_key
=
self
.
course
.
id
self
.
course_mode
=
CourseMode
(
course_id
=
self
.
course_key
,
mode_slug
=
"verified"
,
mode_display_name
=
"verified cert"
,
min_price
=
self
.
COST
)
self
.
course_mode
.
save
()
self
.
cart
=
Order
.
get_cart_for_user
(
self
.
user
)
self
.
client
.
login
(
username
=
self
.
user
.
username
,
password
=
self
.
PASSWORD
)
@patch.dict
(
settings
.
FEATURES
,
{
'SEPARATE_VERIFICATION_FROM_PAYMENT'
:
True
})
def
test_show_receipt_redirect_to_verify_student
(
self
):
# Purchase a verified certificate
CertificateItem
.
add_to_order
(
self
.
cart
,
self
.
course_key
,
self
.
COST
,
'verified'
)
self
.
cart
.
purchase
()
# Visit the receipt page
url
=
reverse
(
'shoppingcart.views.show_receipt'
,
args
=
[
self
.
cart
.
id
])
resp
=
self
.
client
.
get
(
url
)
# Expect to be redirected to the payment confirmation
# page in the verify_student app
redirect_url
=
reverse
(
'verify_student_payment_confirmation'
,
kwargs
=
{
'course_id'
:
unicode
(
self
.
course_key
)}
)
redirect_url
+=
'?payment-order-num={order_num}'
.
format
(
order_num
=
self
.
cart
.
id
)
self
.
assertRedirects
(
resp
,
redirect_url
)
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
@override_settings
(
MODULESTORE
=
MODULESTORE_CONFIG
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
class
ShoppingcartViewsClosedEnrollment
(
ModuleStoreTestCase
):
class
ShoppingcartViewsClosedEnrollment
(
ModuleStoreTestCase
):
...
...
lms/djangoapps/shoppingcart/views.py
View file @
c68426c3
...
@@ -794,6 +794,23 @@ def _show_receipt_html(request, order):
...
@@ -794,6 +794,23 @@ def _show_receipt_html(request, order):
receipt_template
=
order_items
[
0
]
.
single_item_receipt_template
receipt_template
=
order_items
[
0
]
.
single_item_receipt_template
context
.
update
(
order_items
[
0
]
.
single_item_receipt_context
)
context
.
update
(
order_items
[
0
]
.
single_item_receipt_context
)
# TODO (ECOM-188): Once the A/B test of separate verified / payment flow
# completes, implement this in a more general way. For now,
# we simply redirect to the new receipt page (in verify_student).
if
settings
.
FEATURES
.
get
(
'SEPARATE_VERIFICATION_FROM_PAYMENT'
):
if
receipt_template
==
'shoppingcart/verified_cert_receipt.html'
:
url
=
reverse
(
'verify_student_payment_confirmation'
,
kwargs
=
{
'course_id'
:
unicode
(
order_items
[
0
]
.
course_id
)}
)
# Add a query string param for the order ID
# This allows the view to query for the receipt information later.
url
+=
'?payment-order-num={order_num}'
.
format
(
order_num
=
order_items
[
0
]
.
id
)
return
HttpResponseRedirect
(
url
)
return
render_to_response
(
receipt_template
,
context
)
return
render_to_response
(
receipt_template
,
context
)
...
...
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