remove discount banner from track selection
This commit is contained in:
@@ -219,7 +219,7 @@ class TestCourseHomePage(CourseHomePageTestCase):
|
||||
|
||||
# Fetch the view and verify the query counts
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
with self.assertNumQueries(88, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
with self.assertNumQueries(90, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
|
||||
with check_mongo_calls(4):
|
||||
url = course_home_url(self.course)
|
||||
self.client.get(url)
|
||||
|
||||
@@ -14,10 +14,12 @@ from datetime import datetime, timedelta
|
||||
|
||||
from crum import get_current_request, impersonate
|
||||
from django.utils import timezone
|
||||
from django.utils.dateparse import parse_datetime
|
||||
import pytz
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from entitlements.models import CourseEntitlement
|
||||
from experiments.models import ExperimentData
|
||||
from lms.djangoapps.experiments.stable_bucketing import stable_bucketing_hash_group
|
||||
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
|
||||
from openedx.features.discounts.models import DiscountPercentageConfig, DiscountRestrictionConfig
|
||||
@@ -42,6 +44,7 @@ DISCOUNT_APPLICABILITY_FLAG = WaffleFlag(
|
||||
)
|
||||
|
||||
DISCOUNT_APPLICABILITY_HOLDBACK = 'first_purchase_discount_holdback'
|
||||
REV1008_EXPERIMENT_ID = 15
|
||||
|
||||
|
||||
def get_discount_expiration_date(user, course):
|
||||
@@ -61,23 +64,33 @@ def get_discount_expiration_date(user, course):
|
||||
if len(course_enrollment) != 1:
|
||||
return None
|
||||
|
||||
enrollment = course_enrollment.first()
|
||||
time_limit_start = None
|
||||
try:
|
||||
# Content availability date is equivalent to max(enrollment date, course start date)
|
||||
# for most people. Using the schedule date will provide flexibility to deal with
|
||||
# more complex business rules in the future.
|
||||
content_availability_date = enrollment.schedule.start
|
||||
# We have anecdotally observed a case where the schedule.start was
|
||||
# equal to the course start, but should have been equal to the enrollment start
|
||||
# https://openedx.atlassian.net/browse/PROD-58
|
||||
# This section is meant to address that case
|
||||
if enrollment.created and course.start:
|
||||
if (content_availability_date.date() == course.start.date() and
|
||||
course.start < enrollment.created < timezone.now()):
|
||||
content_availability_date = enrollment.created
|
||||
except CourseEnrollment.schedule.RelatedObjectDoesNotExist:
|
||||
content_availability_date = max(enrollment.created, course.start)
|
||||
discount_expiration_date = content_availability_date + timedelta(weeks=1)
|
||||
saw_banner = ExperimentData.objects.get(user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(course))
|
||||
time_limit_start = parse_datetime(saw_banner.value)
|
||||
except ExperimentData.DoesNotExist:
|
||||
pass
|
||||
|
||||
if not time_limit_start:
|
||||
enrollment = course_enrollment.first()
|
||||
try:
|
||||
# Content availability date is equivalent to max(enrollment date, course start date)
|
||||
# for most people. Using the schedule date will provide flexibility to deal with
|
||||
# more complex business rules in the future.
|
||||
content_availability_date = enrollment.schedule.start
|
||||
# We have anecdotally observed a case where the schedule.start was
|
||||
# equal to the course start, but should have been equal to the enrollment start
|
||||
# https://openedx.atlassian.net/browse/PROD-58
|
||||
# This section is meant to address that case
|
||||
if enrollment.created and course.start:
|
||||
if (content_availability_date.date() == course.start.date() and
|
||||
course.start < enrollment.created < timezone.now()):
|
||||
content_availability_date = enrollment.created
|
||||
except CourseEnrollment.schedule.RelatedObjectDoesNotExist:
|
||||
content_availability_date = max(enrollment.created, course.start)
|
||||
time_limit_start = content_availability_date
|
||||
|
||||
discount_expiration_date = time_limit_start + timedelta(weeks=1)
|
||||
|
||||
# If the course has an upgrade deadline and discount time limit would put the discount expiration date
|
||||
# after the deadline, then change the expiration date to be the upgrade deadline
|
||||
|
||||
@@ -2,11 +2,17 @@
|
||||
Utility functions for working with discounts and discounted pricing.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import six
|
||||
from django.utils.translation import ugettext as _
|
||||
import pytz
|
||||
|
||||
from course_modes.models import get_course_prices, format_course_price
|
||||
from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from experiments.models import ExperimentData
|
||||
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
from web_fragments.fragment import Fragment
|
||||
from openedx.features.discounts.applicability import (
|
||||
@@ -15,6 +21,8 @@ from openedx.features.discounts.applicability import (
|
||||
discount_percentage
|
||||
)
|
||||
|
||||
REV1008_EXPERIMENT_ID = 15
|
||||
|
||||
|
||||
def offer_banner_wrapper(user, block, view, frag, context): # pylint: disable=W0613
|
||||
"""
|
||||
@@ -95,7 +103,15 @@ def get_first_purchase_offer_banner_fragment(user, course):
|
||||
which has the discount_expiration_date, price,
|
||||
discount percentage and a link to upgrade.
|
||||
"""
|
||||
if user and course:
|
||||
if user and not user.is_anonymous and course:
|
||||
now = datetime.now(tz=pytz.UTC).strftime(u"%Y-%m-%d %H:%M:%S%z")
|
||||
saw_banner = ExperimentData.objects.filter(
|
||||
user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(course)
|
||||
)
|
||||
if not saw_banner:
|
||||
ExperimentData.objects.create(
|
||||
user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(course), value=now
|
||||
)
|
||||
discount_expiration_date = get_discount_expiration_date(user, course)
|
||||
if (discount_expiration_date and
|
||||
can_receive_discount(user=user, course=course, discount_expiration_date=discount_expiration_date)):
|
||||
|
||||
Reference in New Issue
Block a user