Add price information to enrollments and create dashboard_metadata
for experiments. REVEM-174
This commit is contained in:
@@ -475,7 +475,7 @@ class CourseMode(models.Model):
|
||||
@classmethod
|
||||
def min_course_price_for_verified_for_currency(cls, course_id, currency): # pylint: disable=invalid-name
|
||||
"""
|
||||
Returns the minimum price of the course int he appropriate currency over all the
|
||||
Returns the minimum price of the course in the appropriate currency over all the
|
||||
course's *verified*, non-expired modes.
|
||||
|
||||
Assuming all verified courses have a minimum price of >0, this value should always
|
||||
|
||||
@@ -54,7 +54,7 @@ from edx_django_utils.cache import RequestCache
|
||||
import lms.lib.comment_client as cc
|
||||
from student.signals import UNENROLL_DONE, ENROLL_STATUS_CHANGE, ENROLLMENT_TRACK_UPDATED
|
||||
from lms.djangoapps.certificates.models import GeneratedCertificate
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.models import CourseMode, get_cosmetic_display_price
|
||||
from courseware.models import (
|
||||
CourseDynamicUpgradeDeadlineConfiguration,
|
||||
DynamicUpgradeDeadlineConfiguration,
|
||||
@@ -1075,6 +1075,10 @@ class CourseEnrollment(models.Model):
|
||||
on_delete=models.DO_NOTHING,
|
||||
)
|
||||
|
||||
@property
|
||||
def course_price(self):
|
||||
return get_cosmetic_display_price(self.course)
|
||||
|
||||
@property
|
||||
def course_id(self):
|
||||
return self._course_id
|
||||
|
||||
@@ -22,7 +22,7 @@ from six import text_type, iteritems
|
||||
|
||||
import track.views
|
||||
from bulk_email.models import BulkEmailFlag, Optout # pylint: disable=import-error
|
||||
from course_modes.models import CourseMode
|
||||
from course_modes.models import CourseMode, get_cosmetic_display_price
|
||||
from courseware.access import has_access
|
||||
from edxmako.shortcuts import render_to_response, render_to_string
|
||||
from entitlements.models import CourseEntitlement
|
||||
@@ -42,7 +42,7 @@ from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
|
||||
from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_feature_enabled_for_user
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.features.enterprise_support.api import get_dashboard_consent_notification
|
||||
from openedx.features.enterprise_support.utils import is_enterprise_learner
|
||||
from lms.djangoapps.experiments.utils import get_experiment_dashboard_metadata_context
|
||||
from openedx.features.journals.api import journals_enabled
|
||||
from shoppingcart.api import order_history
|
||||
from shoppingcart.models import CourseRegistrationCode, DonationConfiguration
|
||||
@@ -60,6 +60,13 @@ from xmodule.modulestore.django import modulestore
|
||||
|
||||
log = logging.getLogger("edx.student")
|
||||
|
||||
experiments_namespace = WaffleFlagNamespace(name=u'student.experiments')
|
||||
#TODO START: Delete waffle flag as part of REVEM-204.
|
||||
dashboard_metadata_flag = WaffleFlag(experiments_namespace,
|
||||
u'dashboard_metadata',
|
||||
flag_undefined_default=False)
|
||||
#TODO END: REVEM-204
|
||||
|
||||
|
||||
def get_org_black_and_whitelist_for_site():
|
||||
"""
|
||||
@@ -695,7 +702,7 @@ def student_dashboard(request):
|
||||
inverted_programs = meter.invert_programs()
|
||||
|
||||
urls, programs_data = {}, {}
|
||||
bundles_on_dashboard_flag = WaffleFlag(WaffleFlagNamespace(name=u'student.experiments'), u'bundles_on_dashboard')
|
||||
bundles_on_dashboard_flag = WaffleFlag(experiments_namespace, u'bundles_on_dashboard')
|
||||
|
||||
# TODO: Delete this code and the relevant HTML code after testing LEARNER-3072 is complete
|
||||
if bundles_on_dashboard_flag.is_enabled() and inverted_programs and inverted_programs.items():
|
||||
@@ -869,6 +876,10 @@ def student_dashboard(request):
|
||||
'empty_dashboard_message': empty_dashboard_message,
|
||||
'recovery_email_message': recovery_email_message,
|
||||
'recovery_email_activation_message': recovery_email_activation_message,
|
||||
# TODO START: Clean up REVEM-205 & REVEM-204.
|
||||
# The below context is for experiments in dashboard_metadata
|
||||
'course_prices': get_experiment_dashboard_metadata_context(course_enrollments) if dashboard_metadata_flag.is_enabled() else None,
|
||||
# TODO END: Clean up REVEM-205 & REVEM-204.
|
||||
}
|
||||
|
||||
if ecommerce_service.is_enabled(request.user):
|
||||
|
||||
@@ -191,3 +191,15 @@ def get_experiment_user_metadata_context(course, user):
|
||||
'program_key_fields': program_key,
|
||||
# TODO: clean up as part of REVEM-199 (END)
|
||||
}
|
||||
|
||||
|
||||
#TODO START: Clean up REVEM-205
|
||||
def get_experiment_dashboard_metadata_context(enrollments):
|
||||
"""
|
||||
Given a list of enrollments return a dict of course ids with their prices.
|
||||
Utility function for experimental metadata. See experiments/dashboard_metadata.html.
|
||||
:param enrollments:
|
||||
:return: dict of courses: course price for dashboard metadata
|
||||
"""
|
||||
return {str(enrollment.course): enrollment.course_price for enrollment in enrollments}
|
||||
#TODO END: Clean up REVEM-205
|
||||
|
||||
@@ -361,3 +361,4 @@ from student.models import CourseEnrollment
|
||||
</div>
|
||||
|
||||
<%include file="dashboard/_dashboard_entitlement_unenrollment_modal.html"/>
|
||||
<%include file="/experiments/dashboard_metadata.html" args='course_prices=course_prices'/>
|
||||
|
||||
14
lms/templates/experiments/dashboard_metadata.html
Normal file
14
lms/templates/experiments/dashboard_metadata.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<%page args="course_prices" expression_filter="h"/>
|
||||
<%!
|
||||
from openedx.core.djangolib.js_utils import dump_js_escaped_json
|
||||
%>
|
||||
|
||||
<!-- TODO START: Clean up REVEM-205.-->
|
||||
<%
|
||||
dashboard_metadata = { 'course_prices': course_prices }
|
||||
%>
|
||||
|
||||
<script type="application/json" id="dashboard-metadata">
|
||||
${dashboard_metadata | n , dump_js_escaped_json}
|
||||
</script>
|
||||
<!-- TODO END: Clean up REVEM-205.-->
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
## Pages currently use v1 styling by default. Once the Pattern Library
|
||||
## rollout has been completed, this default can be switched to v2.
|
||||
<%page expression_filter="h"/>
|
||||
<%! main_css = "style-main-v1" %>
|
||||
|
||||
|
||||
@@ -128,14 +129,13 @@ from pipeline_mako import render_require_js_path_overrides
|
||||
<%block name="head_extra"/>
|
||||
|
||||
<%include file="/courseware/experiments.html"/>
|
||||
<%include file="user_metadata.html"/>
|
||||
<%include file="/experiments/user_metadata.html"/>
|
||||
<%static:optional_include_mako file="head-extra.html" is_theming_enabled="True" />
|
||||
|
||||
<%include file="widgets/optimizely.html" />
|
||||
<%include file="widgets/segment-io.html" />
|
||||
|
||||
<meta name="path_prefix" content="${EDX_ROOT_URL}">
|
||||
|
||||
<% google_site_verification_id = configuration_helpers.get_value('GOOGLE_SITE_VERIFICATION_ID', settings.GOOGLE_SITE_VERIFICATION_ID) %>
|
||||
% if google_site_verification_id:
|
||||
<meta name="google-site-verification" content="${google_site_verification_id}" />
|
||||
|
||||
Reference in New Issue
Block a user