From c3180cdea2b68eff8c9081d431f636da2869abc4 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 21 Jul 2020 15:25:42 -0400 Subject: [PATCH] DEPR-43 - Remove donation logic from student dashboard. --- .../student/tests/test_recent_enrollments.py | 86 ------------------- common/djangoapps/student/views/dashboard.py | 48 ----------- lms/static/sass/multicourse/_dashboard.scss | 47 ---------- .../enrollment/course_enrollment_message.html | 21 +---- 4 files changed, 2 insertions(+), 200 deletions(-) diff --git a/common/djangoapps/student/tests/test_recent_enrollments.py b/common/djangoapps/student/tests/test_recent_enrollments.py index e1fecb58ac..af90a8376a 100644 --- a/common/djangoapps/student/tests/test_recent_enrollments.py +++ b/common/djangoapps/student/tests/test_recent_enrollments.py @@ -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") diff --git a/common/djangoapps/student/views/dashboard.py b/common/djangoapps/student/views/dashboard.py index b7e1bd9772..f8ca88f3e1 100644 --- a/common/djangoapps/student/views/dashboard.py +++ b/common/djangoapps/student/views/dashboard.py @@ -45,7 +45,6 @@ from openedx.core.djangoapps.util.maintenance_banner import add_maintenance_bann 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 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 ( @@ -109,47 +108,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. @@ -179,11 +137,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( @@ -191,7 +144,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 } diff --git a/lms/static/sass/multicourse/_dashboard.scss b/lms/static/sass/multicourse/_dashboard.scss index 01150d769b..7eb5384443 100644 --- a/lms/static/sass/multicourse/_dashboard.scss +++ b/lms/static/sass/multicourse/_dashboard.scss @@ -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; - } - } - } } } } diff --git a/lms/templates/enrollment/course_enrollment_message.html b/lms/templates/enrollment/course_enrollment_message.html index cfc2ec8637..92885caae4 100644 --- a/lms/templates/enrollment/course_enrollment_message.html +++ b/lms/templates/enrollment/course_enrollment_message.html @@ -1,8 +1,8 @@ <%! from django.utils.translation import ugettext as _ %> <%page expression_filter="h"/>
-
-