Commit 3d955523 by Chris Dodge

allow for overrides on ENABLE_PAID_COURSE_REIGSTRATIONS via mircosites

parent 01c029aa
...@@ -7,6 +7,7 @@ navigation. We want to do this in the context_processor to ...@@ -7,6 +7,7 @@ navigation. We want to do this in the context_processor to
""" """
from django.conf import settings from django.conf import settings
import shoppingcart import shoppingcart
from microsite_configuration import microsite
def user_has_cart_context_processor(request): def user_has_cart_context_processor(request):
...@@ -15,12 +16,24 @@ def user_has_cart_context_processor(request): ...@@ -15,12 +16,24 @@ def user_has_cart_context_processor(request):
be displayed. Anonymous users don't. be displayed. Anonymous users don't.
Adds `display_shopping_cart` to the context Adds `display_shopping_cart` to the context
""" """
return {'display_shopping_cart': ( display_shopping_cart = (
request.user.is_authenticated() and # user is logged in and # user is logged in and
settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION') and # settings enable paid course reg and request.user.is_authenticated() and
settings.FEATURES.get('ENABLE_SHOPPING_CART') and # settings enable shopping cart and # settings enable paid course reg
microsite.get_value(
'ENABLE_PAID_COURSE_REGISTRATION',
settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION')
) and
# settings enable shopping cart
microsite.get_value(
'ENABLE_SHOPPING_CART',
settings.FEATURES.get('ENABLE_SHOPPING_CART')
) and
# user's cart has PaidCourseRegistrations
shoppingcart.models.Order.user_cart_has_items( shoppingcart.models.Order.user_cart_has_items(
request.user, request.user,
[shoppingcart.models.PaidCourseRegistration, shoppingcart.models.CourseRegCodeItem] [shoppingcart.models.PaidCourseRegistration, shoppingcart.models.CourseRegCodeItem]
) # user's cart has PaidCourseRegistrations )
)} )
return {'display_shopping_cart': display_shopping_cart}
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