Commit 141980b5 by Jesse Zoldak Committed by GitHub

Merge pull request #13176 from edx/revert-13139-asadiqbal08/SOL-1868

Revert "asadiqbal08/SOL-1868 "Go To Dashboard" button should be visible on receipt page"
parents ffe14bb1 0e5fb68e
......@@ -3,17 +3,12 @@
from nose.plugins.attrib import attr
import ddt
import json
from django.core.urlresolvers import reverse
from django.test import TestCase
import mock
from student.tests.factories import UserFactory
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
from xmodule.modulestore.tests.factories import CourseFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from student.models import CourseEnrollment
from course_modes.models import CourseMode
class UserMixin(object):
......@@ -30,22 +25,9 @@ class UserMixin(object):
@attr(shard=1)
@ddt.ddt
class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
class ReceiptViewTests(UserMixin, TestCase):
""" Tests for the receipt view. """
def setUp(self):
"""
Add a user and a course
"""
super(ReceiptViewTests, self).setUp()
self.user = UserFactory()
self.client.login(username=self.user.username, password='test')
self.course = CourseFactory.create(
org='edX',
course='900',
run='test_run'
)
def test_login_required(self):
""" The view should redirect to the login page if the user is not logged in. """
self.client.logout()
......@@ -58,30 +40,6 @@ class ReceiptViewTests(UserMixin, ModuleStoreTestCase):
self.assertEqual(response.status_code, 200)
return response
def test_user_verification_status_success(self):
"""
Test user verification status. If the user enrollment for the course belongs to verified modes
e.g. Verified, Professional then verification is required.
"""
# Enroll as verified in the course with the current user.
CourseEnrollment.enroll(self.user, self.course.id, mode=CourseMode.VERIFIED)
response = self.client.get(reverse('commerce:user_verification_status'), data={'course_id': self.course.id})
json_data = json.loads(response.content)
self.assertEqual(json_data['is_verification_required'], True)
# Enroll as honor in the course with the current user.
CourseEnrollment.enroll(self.user, self.course.id, mode=CourseMode.HONOR)
response = self.client.get(reverse('commerce:user_verification_status'), data={'course_id': self.course.id})
json_data = json.loads(response.content)
self.assertEqual(json_data['is_verification_required'], False)
def test_user_verification_status_failure(self):
"""
Test user verification status failure. View should required HttpResponseBadRequest 400 if course id is missing.
"""
response = self.client.get(reverse('commerce:user_verification_status'))
self.assertEqual(response.status_code, 400)
@ddt.data('decision', 'reason_code', 'signed_field_names', None)
def test_is_cybersource(self, post_key):
"""
......
......@@ -2,6 +2,7 @@
Defines the URL routes for this app.
"""
from django.conf.urls import patterns, url
from commerce import views
......@@ -10,6 +11,4 @@ urlpatterns = patterns(
url(r'^checkout/cancel/$', views.checkout_cancel, name='checkout_cancel'),
url(r'^checkout/error/$', views.checkout_error, name='checkout_error'),
url(r'^checkout/receipt/$', views.checkout_receipt, name='checkout_receipt'),
url(r'^checkout/verification_status/$', views.user_verification_status, name='user_verification_status'),
)
......@@ -13,12 +13,7 @@ from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site
from shoppingcart.processors.CyberSource2 import is_user_payment_error
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from opaque_keys.edx.locator import CourseLocator
from student.models import CourseEnrollment
from util.json_request import JsonResponse
from django.views.decorators.http import require_http_methods
from course_modes.models import CourseMode
from django.http import HttpResponseBadRequest
log = logging.getLogger(__name__)
......@@ -101,22 +96,3 @@ def checkout_receipt(request):
'is_request_in_themed_site': is_request_in_themed_site()
}
return render_to_response('commerce/checkout_receipt.html', context)
@require_http_methods(["GET"])
@login_required
def user_verification_status(request):
"""
Check for user verification status.
:return 'True' if the user enrollment for the course belongs to verified modes e.g. Verified, Professional.
"""
course_id = request.GET.get('course_id', None)
if course_id is None:
return HttpResponseBadRequest()
course_key = CourseLocator.from_string(course_id)
enrollment_mode, __ = CourseEnrollment.enrollment_mode_for_user(request.user, course_key)
is_verification_required = enrollment_mode in CourseMode.VERIFIED_MODES
return JsonResponse({'is_verification_required': is_verification_required})
......@@ -437,8 +437,8 @@ class PayAndVerifyView(View):
return render_to_response("verify_student/pay_and_verify.html", context)
def _redirect_if_necessary(
self, message, already_verified, already_paid, is_enrolled, course_key, # pylint: disable=bad-continuation
user_is_trying_to_pay, user, sku # pylint: disable=bad-continuation
self, message, already_verified, already_paid, is_enrolled, course_key, # pylint: disable=bad-continuation
user_is_trying_to_pay, user, sku # pylint: disable=bad-continuation
):
"""Redirect the user to a more appropriate page if necessary.
......@@ -497,8 +497,8 @@ class PayAndVerifyView(View):
else:
url = reverse('verify_student_start_flow', kwargs=course_kwargs)
if user_is_trying_to_pay and user.is_active and not already_paid:
# If the user is trying to pay, has activated their account, and the ecommerce service
if user_is_trying_to_pay and user.is_active:
# IIf the user is trying to pay, has activated their account, and the ecommerce service
# is enabled redirect him to the ecommerce checkout page.
ecommerce_service = EcommerceService()
if ecommerce_service.is_enabled(user):
......
......@@ -36,36 +36,25 @@ var edx = edx || {};
// Add the receipt info to the template context
this.courseKey = this.getOrderCourseKey(data);
this.username = this.$el.data('username');
var self = this;
$.ajax({
type: "GET",
url: "/commerce/checkout/verification_status/",
data: { course_id: this.courseKey}
}).success(function(response){
_.extend(context, {
receipt: self.receiptContext(data),
courseKey: self.courseKey,
is_verification_required: response.is_verification_required
_.extend(context, {
receipt: this.receiptContext(data),
courseKey: this.courseKey
});
self.$el.html(_.template(templateHtml)(context));
this.$el.html(_.template(templateHtml)(context));
self.trackLinks();
this.trackLinks();
self.trackPurchase(data);
this.trackPurchase(data);
self.renderCourseNamePlaceholder(self.courseKey);
this.renderCourseNamePlaceholder(this.courseKey);
self.renderUserFullNamePlaceholder(self.username);
this.renderUserFullNamePlaceholder(this.username);
providerId = self.getCreditProviderId(data);
if (providerId) {
self.getProviderData(providerId).then(self.renderProvider, self.renderError);
}
}).error(function(){
self.renderError();
});
providerId = this.getCreditProviderId(data);
if (providerId) {
this.getProviderData(providerId).then(this.renderProvider, this.renderError)
}
},
renderCourseNamePlaceholder: function (courseId) {
// Display the course Id or name (if available) in the placeholder
......
......@@ -37,11 +37,6 @@ define([
mockRequests(requests, 'GET', orderUrlFormat, data);
mockRequests(
requests, 'GET', '/commerce/checkout/verification_status/?course_id=' +
encodeURIComponent('course-v1:edx+dummy+2015_T3'), {is_verification_required: true}
);
mockRequests(
requests, 'GET', '/api/courses/v1/courses/course-v1:edx+dummy+2015_T3/', courseResponseData
);
......
......@@ -88,7 +88,7 @@
<% } %>
<nav class="nav-wizard is-ready">
<% if ( !is_verification_required || verified || is_request_in_themed_site) { %>
<% if ( verified || is_request_in_themed_site) { %>
<a class="next action-primary right" href="/dashboard"><%- gettext( "Go to Dashboard" ) %></a>
<% } else { %>
<a id="verify_later_button" class="next action-secondary verify-later nav-link" href="/dashboard" data-tooltip="<%- edx.StringUtils.interpolate( gettext( "If you don't verify your identity now, you can still explore your course from your dashboard. You will receive periodic reminders from {platformName} to verify your identity." ), { platformName: platformName } ) %>">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment