Merge pull request #12664 from edx/rc/2016-06-07-mattdrayer
mattdrayer/WL-493: Enable bulk purchase via Otto for unauthenticated users
This commit is contained in:
@@ -94,7 +94,8 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
|
|||||||
url = reverse('course_modes_choose', args=[unicode(self.course.id)])
|
url = reverse('course_modes_choose', args=[unicode(self.course.id)])
|
||||||
response = self.client.get(url)
|
response = self.client.get(url)
|
||||||
# Check whether we were correctly redirected
|
# Check whether we were correctly redirected
|
||||||
start_flow_url = reverse('verify_student_start_flow', args=[unicode(self.course.id)])
|
purchase_workflow = "?purchase_workflow=single"
|
||||||
|
start_flow_url = reverse('verify_student_start_flow', args=[unicode(self.course.id)]) + purchase_workflow
|
||||||
self.assertRedirects(response, start_flow_url)
|
self.assertRedirects(response, start_flow_url)
|
||||||
|
|
||||||
def test_no_id_redirect_otto(self):
|
def test_no_id_redirect_otto(self):
|
||||||
@@ -194,7 +195,8 @@ class CourseModeViewTest(UrlResetMixin, ModuleStoreTestCase):
|
|||||||
|
|
||||||
# Since the only available track is professional ed, expect that
|
# Since the only available track is professional ed, expect that
|
||||||
# we're redirected immediately to the start of the payment flow.
|
# we're redirected immediately to the start of the payment flow.
|
||||||
start_flow_url = reverse('verify_student_start_flow', args=[unicode(self.course.id)])
|
purchase_workflow = "?purchase_workflow=single"
|
||||||
|
start_flow_url = reverse('verify_student_start_flow', args=[unicode(self.course.id)]) + purchase_workflow
|
||||||
self.assertRedirects(response, start_flow_url)
|
self.assertRedirects(response, start_flow_url)
|
||||||
|
|
||||||
# Now enroll in the course
|
# Now enroll in the course
|
||||||
|
|||||||
@@ -88,12 +88,15 @@ class ChooseModeView(View):
|
|||||||
# If there are both modes, default to non-id-professional.
|
# If there are both modes, default to non-id-professional.
|
||||||
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:
|
||||||
redirect_url = reverse('verify_student_start_flow', kwargs={'course_id': unicode(course_key)})
|
purchase_workflow = request.GET.get("purchase_workflow", "single")
|
||||||
|
verify_url = reverse('verify_student_start_flow', kwargs={'course_id': unicode(course_key)})
|
||||||
|
redirect_url = "{url}?purchase_workflow={workflow}".format(url=verify_url, workflow=purchase_workflow)
|
||||||
if ecommerce_service.is_enabled(request.user):
|
if ecommerce_service.is_enabled(request.user):
|
||||||
professional_mode = modes.get(CourseMode.NO_ID_PROFESSIONAL_MODE) or modes.get(CourseMode.PROFESSIONAL)
|
professional_mode = modes.get(CourseMode.NO_ID_PROFESSIONAL_MODE) or modes.get(CourseMode.PROFESSIONAL)
|
||||||
if professional_mode.sku:
|
if purchase_workflow == "single" and professional_mode.sku:
|
||||||
redirect_url = ecommerce_service.checkout_page_url(professional_mode.sku)
|
redirect_url = ecommerce_service.checkout_page_url(professional_mode.sku)
|
||||||
|
if purchase_workflow == "bulk" and professional_mode.bulk_sku:
|
||||||
|
redirect_url = ecommerce_service.checkout_page_url(professional_mode.bulk_sku)
|
||||||
return redirect(redirect_url)
|
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
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ def auth_pipeline_urls(auth_entry, redirect_url=None):
|
|||||||
|
|
||||||
# Query string parameters that can be passed to the "finish_auth" view to manage
|
# Query string parameters that can be passed to the "finish_auth" view to manage
|
||||||
# things like auto-enrollment.
|
# things like auto-enrollment.
|
||||||
POST_AUTH_PARAMS = ('course_id', 'enrollment_action', 'course_mode', 'email_opt_in')
|
POST_AUTH_PARAMS = ('course_id', 'enrollment_action', 'course_mode', 'email_opt_in', 'purchase_workflow')
|
||||||
|
|
||||||
|
|
||||||
def get_next_url_for_login_page(request):
|
def get_next_url_for_login_page(request):
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class TestProfEdVerification(ModuleStoreTestCase):
|
|||||||
min_price=self.MIN_PRICE,
|
min_price=self.MIN_PRICE,
|
||||||
suggested_prices=''
|
suggested_prices=''
|
||||||
)
|
)
|
||||||
|
purchase_workflow = "?purchase_workflow=single"
|
||||||
self.urls = {
|
self.urls = {
|
||||||
'course_modes_choose': reverse(
|
'course_modes_choose': reverse(
|
||||||
'course_modes_choose',
|
'course_modes_choose',
|
||||||
@@ -42,7 +42,7 @@ class TestProfEdVerification(ModuleStoreTestCase):
|
|||||||
'verify_student_start_flow': reverse(
|
'verify_student_start_flow': reverse(
|
||||||
'verify_student_start_flow',
|
'verify_student_start_flow',
|
||||||
args=[unicode(self.course_key)]
|
args=[unicode(self.course_key)]
|
||||||
),
|
) + purchase_workflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_start_flow(self):
|
def test_start_flow(self):
|
||||||
|
|||||||
@@ -334,6 +334,10 @@ class PayAndVerifyView(View):
|
|||||||
# Redirect the user to a more appropriate page if the
|
# Redirect the user to a more appropriate page if the
|
||||||
# messaging won't make sense based on the user's
|
# messaging won't make sense based on the user's
|
||||||
# enrollment / payment / verification status.
|
# enrollment / payment / verification status.
|
||||||
|
sku_to_use = relevant_course_mode.sku
|
||||||
|
purchase_workflow = request.GET.get('purchase_workflow', 'single')
|
||||||
|
if purchase_workflow == 'bulk' and relevant_course_mode.bulk_sku:
|
||||||
|
sku_to_use = relevant_course_mode.bulk_sku
|
||||||
redirect_response = self._redirect_if_necessary(
|
redirect_response = self._redirect_if_necessary(
|
||||||
message,
|
message,
|
||||||
already_verified,
|
already_verified,
|
||||||
@@ -342,7 +346,7 @@ class PayAndVerifyView(View):
|
|||||||
course_key,
|
course_key,
|
||||||
user_is_trying_to_pay,
|
user_is_trying_to_pay,
|
||||||
request.user,
|
request.user,
|
||||||
relevant_course_mode.sku
|
sku_to_use
|
||||||
)
|
)
|
||||||
if redirect_response is not None:
|
if redirect_response is not None:
|
||||||
return redirect_response
|
return redirect_response
|
||||||
|
|||||||
@@ -51,7 +51,8 @@
|
|||||||
enrollmentAction: $.url( '?enrollment_action' ),
|
enrollmentAction: $.url( '?enrollment_action' ),
|
||||||
courseId: $.url( '?course_id' ),
|
courseId: $.url( '?course_id' ),
|
||||||
courseMode: $.url( '?course_mode' ),
|
courseMode: $.url( '?course_mode' ),
|
||||||
emailOptIn: $.url( '?email_opt_in' )
|
emailOptIn: $.url( '?email_opt_in' ),
|
||||||
|
purchaseWorkflow: $.url( '?purchase_workflow' )
|
||||||
};
|
};
|
||||||
for (var key in queryParams) {
|
for (var key in queryParams) {
|
||||||
if (queryParams[key]) {
|
if (queryParams[key]) {
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
this.courseMode = queryParams.courseMode;
|
this.courseMode = queryParams.courseMode;
|
||||||
this.emailOptIn = queryParams.emailOptIn;
|
this.emailOptIn = queryParams.emailOptIn;
|
||||||
this.nextUrl = this.urls.defaultNextUrl;
|
this.nextUrl = this.urls.defaultNextUrl;
|
||||||
|
this.purchaseWorkflow = queryParams.purchaseWorkflow;
|
||||||
if (queryParams.next) {
|
if (queryParams.next) {
|
||||||
// Ensure that the next URL is internal for security reasons
|
// Ensure that the next URL is internal for security reasons
|
||||||
if ( ! window.isExternal( queryParams.next ) ) {
|
if ( ! window.isExternal( queryParams.next ) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user