not sure why we are getting errors here, but they shouldn't stop people checking out

This commit is contained in:
Emma Green
2020-05-13 16:03:26 -04:00
parent 5724432741
commit 4a9f88b3c1

View File

@@ -5,6 +5,8 @@ The Discount API Views should return information about discounts that apply to t
# -*- coding: utf-8 -*-
import logging
from django.contrib.auth.models import User
from django.utils.decorators import method_decorator
from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication
@@ -24,6 +26,8 @@ from openedx.core.lib.api.view_utils import DeveloperErrorViewMixin
from .applicability import can_receive_discount, discount_percentage, REV1008_EXPERIMENT_ID
log = logging.getLogger(__name__)
class CourseUserDiscount(DeveloperErrorViewMixin, APIView):
"""
@@ -77,12 +81,15 @@ class CourseUserDiscount(DeveloperErrorViewMixin, APIView):
payload = {'discount_applicable': discount_applicable, 'discount_percent': discount_percent}
# Record whether the last basket loaded for this course had a discount
ExperimentData.objects.update_or_create(
user=request.user,
experiment_id=REV1008_EXPERIMENT_ID,
key='discount_' + str(course),
value=discount_applicable
)
try:
ExperimentData.objects.update_or_create(
user=request.user,
experiment_id=REV1008_EXPERIMENT_ID,
key='discount_' + str(course),
value=discount_applicable
)
except Exception as e: # pylint: disable=broad-except
log.exception(str(e))
return Response({
'discount_applicable': discount_applicable,