From 502c8b5bf5951562849aa44ca285778b3401cd18 Mon Sep 17 00:00:00 2001 From: Emma Green Date: Thu, 19 Sep 2019 15:51:57 -0400 Subject: [PATCH] use the specified user from the parameter to determine if the flag is enabled, rather than the request's user --- openedx/features/discounts/applicability.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openedx/features/discounts/applicability.py b/openedx/features/discounts/applicability.py index ba6ebd18b2..1b44baf8f4 100644 --- a/openedx/features/discounts/applicability.py +++ b/openedx/features/discounts/applicability.py @@ -12,7 +12,7 @@ from __future__ import absolute_import from datetime import datetime -import crum +from crum import get_current_request, impersonate import pytz from course_modes.models import CourseMode @@ -49,8 +49,9 @@ def can_receive_discount(user, course): # pylint: disable=unused-argument can receive a discount. """ # Always disable discounts until we are ready to enable this feature - if not DISCOUNT_APPLICABILITY_FLAG.is_enabled(): - return False + with impersonate(user): + if not DISCOUNT_APPLICABILITY_FLAG.is_enabled(): + return False # TODO: Add additional conditions to return False here @@ -94,7 +95,7 @@ def _is_in_holdback(user): # Holdback is 50/50 bucket = stable_bucketing_hash_group(DISCOUNT_APPLICABILITY_HOLDBACK, 2, user.username) - request = crum.get_current_request() + request = get_current_request() if hasattr(request, 'session') and DISCOUNT_APPLICABILITY_HOLDBACK not in request.session: properties = {