Commit a93faad7 by Chris Dodge

try importing the exact references we need rather than deferencing it from the djangoapp module

parent 81c1ae35
......@@ -10,7 +10,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from helpers import LoginEnrollmentTestCase
from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
from course_modes.models import CourseMode
from xmodule.course_module import (
CATALOG_VISIBILITY_CATALOG_AND_ABOUT, CATALOG_VISIBILITY_NONE)
......@@ -55,6 +55,7 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.course_with_visibility = CourseFactory.create(
display_name='visible_course',
org='TestMicrositeX',
course="foo",
catalog_visibility=CATALOG_VISIBILITY_CATALOG_AND_ABOUT,
)
......@@ -189,3 +190,33 @@ class TestMicrosites(ModuleStoreTestCase, LoginEnrollmentTestCase):
url = reverse('about_course', args=[self.course_hidden_visibility.id.to_deprecated_string()])
resp = self.client.get(url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertEqual(resp.status_code, 404)
@override_settings(SITE_NAME=settings.MICROSITE_TEST_HOSTNAME)
def test_paid_course_registration(self):
"""
Make sure that Microsite overrides on the ENABLE_SHOPPING_CART and
ENABLE_PAID_COURSE_ENROLLMENTS are honored
"""
course_mode = CourseMode(
course_id=self.course_with_visibility.id,
mode_slug="honor",
mode_display_name="honor cert",
min_price=10,
)
course_mode.save()
# first try on the non microsite, which
# should pick up the global configuration (where ENABLE_PAID_COURSE_REGISTRATIONS = False)
url = reverse('about_course', args=[self.course_with_visibility.id.to_deprecated_string()])
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
self.assertIn("Register for {}".format(self.course_with_visibility.id.course), resp.content)
self.assertNotIn("Add {} to Cart ($10)".format(self.course_with_visibility.id.course), resp.content)
# now try on the microsite
url = reverse('about_course', args=[self.course_with_visibility.id.to_deprecated_string()])
resp = self.client.get(url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertEqual(resp.status_code, 200)
self.assertNotIn("Register for {}".format(self.course_with_visibility.id.course), resp.content)
self.assertIn("Add {} to Cart ($10)".format(self.course_with_visibility.id.course), resp.content)
self.assertIn('$("#add_to_cart_post").click', resp.content)
......@@ -733,7 +733,8 @@ def course_about(request, course_id):
in_cart = False
reg_then_add_to_cart_link = ""
if (is_shopping_cart_enabled()):
_is_shopping_cart_enabled = is_shopping_cart_enabled()
if (_is_shopping_cart_enabled):
registration_price = CourseMode.min_course_price_for_currency(course_key,
settings.PAID_COURSE_REGISTRATION_CURRENCY[0])
if request.user.is_authenticated():
......@@ -775,6 +776,8 @@ def course_about(request, course_id):
# We do not want to display the internal courseware header, which is used when the course is found in the
# context. This value is therefor explicitly set to render the appropriate header.
'disable_courseware_header': True,
'is_shopping_cart_enabled': _is_shopping_cart_enabled,
'cart_link': reverse('shoppingcart.views.show_cart'),
})
......
......@@ -6,7 +6,8 @@ navigation. We want to do this in the context_processor to
2) because navigation.html is "called" by being included in other templates, there's no "views.py" to put this.
"""
import shoppingcart
from .models import Order, PaidCourseRegistration, CourseRegCodeItem
from .utils import is_shopping_cart_enabled
def user_has_cart_context_processor(request):
......@@ -19,11 +20,11 @@ def user_has_cart_context_processor(request):
# user is logged in and
request.user.is_authenticated() and
# do we have the feature turned on
shoppingcart.utils.is_shopping_cart_enabled() and
is_shopping_cart_enabled() and
# user's cart has PaidCourseRegistrations
shoppingcart.models.Order.user_cart_has_items(
Order.user_cart_has_items(
request.user,
[shoppingcart.models.PaidCourseRegistration, shoppingcart.models.CourseRegCodeItem]
[PaidCourseRegistration, CourseRegCodeItem]
)
)
......
......@@ -352,6 +352,8 @@ MICROSITE_CONFIGURATION = {
"ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER": False,
"COURSE_CATALOG_VISIBILITY_PERMISSION": "see_in_catalog",
"COURSE_ABOUT_VISIBILITY_PERMISSION": "see_about_page",
"ENABLE_SHOPPING_CART": True,
"ENABLE_PAID_COURSE_REGISTRATION": True,
},
"default": {
"university": "default_university",
......
......@@ -4,11 +4,6 @@
from courseware.courses import course_image_url, get_course_about_section
from django.conf import settings
from edxmako.shortcuts import marketing_link
if settings.FEATURES.get('ENABLE_SHOPPING_CART'):
cart_link = reverse('shoppingcart.views.show_cart')
else:
cart_link = ""
%>
<%namespace name='static' file='../static_content.html'/>
<%! from microsite_configuration import microsite %>
......@@ -42,7 +37,7 @@
event.preventDefault();
});
% if settings.FEATURES.get('ENABLE_SHOPPING_CART') and settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION'):
% if is_shopping_cart_enabled:
add_course_complete_handler = function(jqXHR, textStatus) {
if (jqXHR.status == 200) {
location.href = "${cart_link}";
......@@ -162,7 +157,7 @@
## so that they can register and become a real user that can enroll.
% elif not is_shib_course and not can_enroll:
<span class="register disabled">${_("Enrollment is Closed")}</span>
%elif settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION') and registration_price:
%elif is_shopping_cart_enabled and registration_price:
<%
if user.is_authenticated():
reg_href = "#"
......
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