Merge pull request #24558 from edx/feanil/depr-43-remove-donation-button
DEPR-43 - Remove donation logic from student dashboard.
This commit is contained in:
@@ -17,7 +17,6 @@ from six.moves import range, zip
|
||||
from common.test.utils import XssTestMixin
|
||||
from course_modes.tests.factories import CourseModeFactory
|
||||
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration_context
|
||||
from shoppingcart.models import DonationConfiguration
|
||||
from student.models import CourseEnrollment, DashboardConfiguration
|
||||
from student.tests.factories import UserFactory
|
||||
from student.views import get_course_enrollments
|
||||
@@ -204,88 +203,3 @@ class TestRecentEnrollments(ModuleStoreTestCase, XssTestMixin):
|
||||
|
||||
# Check if response is escaped
|
||||
self.assert_no_xss(response, xss_content)
|
||||
|
||||
@ddt.data(
|
||||
# Register as honor in any course modes with no payment option
|
||||
([('audit', 0), ('honor', 0)], 'honor', True),
|
||||
([('honor', 0)], 'honor', True),
|
||||
# Register as honor in any course modes which has payment option
|
||||
([('honor', 10)], 'honor', False), # This is a paid course
|
||||
([('audit', 0), ('honor', 0), ('professional', 20)], 'honor', True),
|
||||
([('audit', 0), ('honor', 0), ('verified', 20)], 'honor', True),
|
||||
([('audit', 0), ('honor', 0), ('verified', 20), ('professional', 20)], 'honor', True),
|
||||
# Register as audit in any course modes with no payment option
|
||||
([('audit', 0), ('honor', 0)], 'audit', True),
|
||||
([('audit', 0)], 'audit', True),
|
||||
([], 'audit', True),
|
||||
# Register as audit in any course modes which has no payment option
|
||||
([('audit', 0), ('honor', 0), ('verified', 10)], 'audit', True),
|
||||
# Register as verified in any course modes which has payment option
|
||||
([('professional', 20)], 'professional', False),
|
||||
([('verified', 20)], 'verified', False),
|
||||
([('professional', 20), ('verified', 20)], 'verified', False),
|
||||
([('audit', 0), ('honor', 0), ('verified', 20)], 'verified', False)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_donate_button(self, course_modes, enrollment_mode, show_donate):
|
||||
# Enable the enrollment success message
|
||||
self._configure_message_timeout(10000)
|
||||
|
||||
# Enable donations
|
||||
DonationConfiguration(enabled=True).save()
|
||||
|
||||
# Create the course mode(s)
|
||||
for mode, min_price in course_modes:
|
||||
CourseModeFactory.create(mode_slug=mode, course_id=self.course.id, min_price=min_price)
|
||||
|
||||
self.enrollment.mode = enrollment_mode
|
||||
self.enrollment.save()
|
||||
|
||||
# Check that the donate button is or is not displayed
|
||||
self.client.login(username=self.student.username, password=self.PASSWORD)
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
|
||||
if show_donate:
|
||||
self.assertContains(response, "donate-container")
|
||||
else:
|
||||
self.assertNotContains(response, "donate-container")
|
||||
|
||||
def test_donate_button_honor_with_price(self):
|
||||
# Enable the enrollment success message and donations
|
||||
self._configure_message_timeout(10000)
|
||||
DonationConfiguration(enabled=True).save()
|
||||
|
||||
# Create a white-label course mode
|
||||
# (honor mode with a price set)
|
||||
CourseModeFactory.create(mode_slug="honor", course_id=self.course.id, min_price=100)
|
||||
|
||||
# Check that the donate button is NOT displayed
|
||||
self.client.login(username=self.student.username, password=self.PASSWORD)
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
self.assertNotContains(response, "donate-container")
|
||||
|
||||
@ddt.data(
|
||||
(True, False,),
|
||||
(True, True,),
|
||||
(False, False,),
|
||||
(False, True,),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_donate_button_with_enabled_site_configuration(self, enable_donation_config, enable_donation_site_config):
|
||||
# Enable the enrollment success message and donations
|
||||
self._configure_message_timeout(10000)
|
||||
|
||||
# DonationConfiguration has low precedence if 'ENABLE_DONATIONS' is enable in SiteConfiguration
|
||||
DonationConfiguration(enabled=enable_donation_config).save()
|
||||
|
||||
CourseModeFactory.create(mode_slug="audit", course_id=self.course.id, min_price=0)
|
||||
self.enrollment.mode = "audit"
|
||||
self.enrollment.save()
|
||||
self.client.login(username=self.student.username, password=self.PASSWORD)
|
||||
|
||||
with with_site_configuration_context(configuration={'ENABLE_DONATIONS': enable_donation_site_config}):
|
||||
response = self.client.get(reverse("dashboard"))
|
||||
if enable_donation_site_config:
|
||||
self.assertContains(response, "donate-container")
|
||||
else:
|
||||
self.assertNotContains(response, "donate-container")
|
||||
|
||||
@@ -44,11 +44,11 @@ from openedx.core.djangoapps.user_api.accounts.utils import is_secondary_email_f
|
||||
from openedx.core.djangoapps.util.maintenance_banner import add_maintenance_banner
|
||||
from openedx.core.djangoapps.waffle_utils import WaffleFlag, WaffleFlagNamespace
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.features.enterprise_support.api import get_dashboard_consent_notification
|
||||
from openedx.features.enterprise_support.api import (
|
||||
get_dashboard_consent_notification,
|
||||
get_enterprise_learner_portal_enabled_message,
|
||||
)
|
||||
from shoppingcart.models import DonationConfiguration
|
||||
from student.api import COURSE_DASHBOARD_PLUGIN_VIEW_NAME
|
||||
from student.helpers import cert_info, check_verify_status_by_course, get_resume_urls_for_enrollments
|
||||
from student.models import (
|
||||
@@ -112,47 +112,6 @@ def _get_recently_enrolled_courses(course_enrollments):
|
||||
]
|
||||
|
||||
|
||||
def _allow_donation(course_modes, course_id, enrollment):
|
||||
"""
|
||||
Determines if the dashboard will request donations for the given course.
|
||||
|
||||
Check if donations are configured for the platform, and if the current course is accepting donations.
|
||||
|
||||
Args:
|
||||
course_modes (dict): Mapping of course ID's to course mode dictionaries.
|
||||
course_id (str): The unique identifier for the course.
|
||||
enrollment(CourseEnrollment): The enrollment object in which the user is enrolled
|
||||
|
||||
Returns:
|
||||
True if the course is allowing donations.
|
||||
|
||||
"""
|
||||
if course_id not in course_modes:
|
||||
flat_unexpired_modes = {
|
||||
text_type(course_id): [mode for mode in modes]
|
||||
for course_id, modes in iteritems(course_modes)
|
||||
}
|
||||
flat_all_modes = {
|
||||
text_type(course_id): [mode.slug for mode in modes]
|
||||
for course_id, modes in iteritems(CourseMode.all_modes_for_courses([course_id]))
|
||||
}
|
||||
log.error(
|
||||
u'Can not find `%s` in course modes.`%s`. All modes: `%s`',
|
||||
course_id,
|
||||
flat_unexpired_modes,
|
||||
flat_all_modes
|
||||
)
|
||||
donations_enabled = configuration_helpers.get_value(
|
||||
'ENABLE_DONATIONS',
|
||||
DonationConfiguration.current().enabled
|
||||
)
|
||||
return (
|
||||
donations_enabled and
|
||||
enrollment.mode in course_modes[course_id] and
|
||||
course_modes[course_id][enrollment.mode].min_price == 0
|
||||
)
|
||||
|
||||
|
||||
def _create_recent_enrollment_message(course_enrollments, course_modes):
|
||||
"""
|
||||
Builds a recent course enrollment message.
|
||||
@@ -182,11 +141,6 @@ def _create_recent_enrollment_message(course_enrollments, course_modes):
|
||||
[enrollment.course_overview.display_name for enrollment in recently_enrolled_courses]
|
||||
)
|
||||
|
||||
allow_donations = any(
|
||||
_allow_donation(course_modes, enrollment.course_overview.id, enrollment)
|
||||
for enrollment in recently_enrolled_courses
|
||||
)
|
||||
|
||||
platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
|
||||
|
||||
return render_to_string(
|
||||
@@ -194,7 +148,6 @@ def _create_recent_enrollment_message(course_enrollments, course_modes):
|
||||
{
|
||||
'course_names': course_names,
|
||||
'enrollments_count': enrollments_count,
|
||||
'allow_donations': allow_donations,
|
||||
'platform_name': platform_name,
|
||||
'course_id': recently_enrolled_courses[0].course_overview.id if enrollments_count == 1 else None
|
||||
}
|
||||
|
||||
@@ -1444,53 +1444,6 @@ a.fade-cover {
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
&.has-actions {
|
||||
.donate-content {
|
||||
width: flex-grid(8, 12);
|
||||
}
|
||||
|
||||
.donate-actions {
|
||||
width: flex-grid(4, 12);
|
||||
vertical-align: bottom;
|
||||
display: inline-block;
|
||||
|
||||
.monetary-symbol {
|
||||
vertical-align: middle;
|
||||
color: $white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.amount {
|
||||
height: 40px;
|
||||
width: 80px;
|
||||
vertical-align: middle;
|
||||
text-align: left;
|
||||
border: 2px solid $white;
|
||||
|
||||
&.validation-error {
|
||||
border: 2px solid $error-color;
|
||||
}
|
||||
}
|
||||
|
||||
.action-donate {
|
||||
@extend %btn-primary-blue;
|
||||
|
||||
vertical-align: middle;
|
||||
padding-top: ($baseline/2);
|
||||
padding-bottom: ($baseline/2);
|
||||
text-shadow: none;
|
||||
text-transform: none;
|
||||
letter-spacing: 0;
|
||||
color: $white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.donation-error-msg {
|
||||
padding: ($baseline/2) 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
<%page expression_filter="h"/>
|
||||
<div class="wrapper-msg urgency-high">
|
||||
<div class="msg has-actions">
|
||||
<div class="msg-content donate-content">
|
||||
<div class="msg">
|
||||
<div class="msg-content">
|
||||
<h2 class="sr">${_("Enrollment Successful")}</h2>
|
||||
<div class="copy">
|
||||
% if enrollments_count == 1:
|
||||
@@ -12,24 +12,7 @@
|
||||
${course_names}
|
||||
<p>${_("We hope you enjoy the course.")}</p>
|
||||
% endif
|
||||
% if allow_donations:
|
||||
<p>
|
||||
${_("{platform_name} is a nonprofit bringing high-quality education to everyone, everywhere. "
|
||||
"Your help allows us to continuously improve the learning experience for millions and "
|
||||
"make a better future one learner at a time.").format(platform_name=platform_name)}
|
||||
</p>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
% if allow_donations:
|
||||
<div class="nav-actions donate-actions">
|
||||
<h3 class="sr">${_('Donation Actions')}</h3>
|
||||
% if course_id:
|
||||
<div class="donate-container" data-course="${ course_id }"></div>
|
||||
% else:
|
||||
<div class="donate-container"></div>
|
||||
% endif
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user