include email settings in fulfilled entitlement action items

This commit is contained in:
McKenzie Welter
2017-12-18 13:22:18 -05:00
parent 9f921bf618
commit a4d23eaea9
6 changed files with 59 additions and 12 deletions

View File

@@ -131,7 +131,6 @@
if ($(event.target).data('optout') === 'False') {
$('#receive_emails').prop('checked', true);
}
edx.dashboard.dropdown.toggleCourseActionsDropdownMenu(event);
});
$('.action-unenroll').click(function(event) {
var isPaidCourse = $(event.target).data('course-is-paid-course') === 'True';
@@ -211,6 +210,7 @@
});
$('.action-email-settings').each(function(index) {
$(this).attr('id', 'email-settings-' + index);
// a bit of a hack, but gets the unique selector for the modal trigger
var trigger = '#' + $(this).attr('id');
accessibleModal(
@@ -219,7 +219,6 @@
'#email-settings-modal',
'#dashboard-main'
);
$(this).attr('id', 'email-settings-' + index);
});
$('.action-unenroll').each(function(index) {

View File

@@ -167,14 +167,17 @@ from student.models import CourseEnrollment
if not next_session:
continue
enrollment = CourseEnrollment(user=user, course_id=next_session['key'], mode=next_session['type'])
# We only show email settings for entitlement cards if the entitlement has an associated enrollment
show_email_settings = is_fulfilled_entitlement and (entitlement_session.course_id in show_email_settings_for)
else:
show_email_settings = (enrollment.course_id in show_email_settings_for)
session_id = enrollment.course_id
show_courseware_link = (session_id in show_courseware_links_for)
cert_status = cert_statuses.get(session_id)
can_refund_entitlement = entitlement and entitlement.is_entitlement_refundable()
can_unenroll = (not cert_status) or cert_status.get('can_unenroll') if not unfulfilled_entitlement else False
credit_status = credit_statuses.get(session_id)
show_email_settings = (session_id in show_email_settings_for)
course_mode_info = all_course_modes.get(session_id)
is_paid_course = True if entitlement else (session_id in enrolled_courses_either_paid)
is_course_blocked = (session_id in block_courses)

View File

@@ -235,11 +235,11 @@ from util.course import get_link_for_about_page, get_encoded_course_sharing_utm_
% endif
% endif
## Right now, the gear dropdown for entitlements only contains the 'unenroll' link, so we should hide the
## gear altogether if the user is unable to unenroll/refund their entitlement. Later, when we add more options
## to the gear dropdown, we can remove this check.
% if entitlement and can_refund_entitlement:
<%include file='_dashboard_entitlement_actions.html' args='course_overview=course_overview,entitlement=entitlement,dashboard_index=dashboard_index, can_refund_entitlement=can_refund_entitlement'/>
## We should only show the gear dropdown if the user is able to refund/unenroll from their entitlement
## and/or if they have selected a course run and email_settings are enabled
## as these are the only actions currently available
% if entitlement and (can_refund_entitlement or show_email_settings):
<%include file='_dashboard_entitlement_actions.html' args='course_overview=course_overview,entitlement=entitlement,dashboard_index=dashboard_index, can_refund_entitlement=can_refund_entitlement, show_email_settings=show_email_settings'/>
% elif not entitlement:
<div class="wrapper-action-more" data-course-key="${enrollment.course_id}">
<button type="button" class="action action-more" id="actions-dropdown-link-${dashboard_index}" aria-haspopup="true" aria-expanded="false" aria-controls="actions-dropdown-${dashboard_index}" data-course-number="${course_overview.number}" data-course-name="${course_overview.display_name_with_default}" data-dashboard-index="${dashboard_index}">

View File

@@ -1,4 +1,4 @@
<%page args="course_overview, entitlement, dashboard_index, can_refund_entitlement" expression_filter="h"/>
<%page args="course_overview, entitlement, dashboard_index, can_refund_entitlement, show_email_settings" expression_filter="h"/>
<%!
from django.utils.translation import ugettext as _
@@ -43,6 +43,19 @@ dropdown_btn_id = "entitlement-actions-dropdown-btn-{}".format(dashboard_index)
</a>
</li>
% endif
</ul>
% if show_email_settings:
<li class="entitlement-actions-item" id="actions-item-email-settings-${dashboard_index}" role="menuitem">
## href and rel must be defined for compatibility with lms/static/js/leanModal.js
## data-dropdown-selector and data-dropdown-button-selector must be defined for compatibility with lms/static/js/dashboard/dropdown.js
<a href="#email-settings-modal" class="entitlement-action action-email-settings" rel="leanModal"
data-dropdown-selector="#${dropdown_id}"
data-dropdown-button-selector="#${dropdown_btn_id}"
data-course-id="${course_overview.id}"
data-course-number="${course_overview.number}"
data-dashboard-index="${dashboard_index}"
data-optout="${unicode(course_overview.id) in course_optouts}">${_('Email Settings')}</a>
</li>
% endif
</ul>
</div>
</div>