diff --git a/enterprise/admin/forms.py b/enterprise/admin/forms.py index 7262a766d9..695aa6c181 100644 --- a/enterprise/admin/forms.py +++ b/enterprise/admin/forms.py @@ -400,7 +400,6 @@ class Meta: "enable_audit_data_reporting", "replace_sensitive_sso_username", "hide_course_original_price", - "hide_course_price_when_zero", "allow_enrollment_in_invite_only_courses", "enable_portal_code_management_screen", "enable_portal_subscription_management_screen", diff --git a/enterprise/migrations/0173_remove_hide_price_when_zero.py b/enterprise/migrations/0173_remove_hide_price_when_zero.py new file mode 100644 index 0000000000..50a97fc546 --- /dev/null +++ b/enterprise/migrations/0173_remove_hide_price_when_zero.py @@ -0,0 +1,21 @@ +# Generated by Django 3.2.21 on 2024-12-02 06:52 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('enterprise', '0172_adds_allow_enrollment_in_invite_only_courses_flag'), + ] + + operations = [ + migrations.RemoveField( + model_name='enterprisecustomer', + name='hide_course_price_when_zero', + ), + migrations.RemoveField( + model_name='historicalenterprisecustomer', + name='hide_course_price_when_zero', + ), + ] diff --git a/enterprise/models.py b/enterprise/models.py index a9475d8f9b..b8a1465d57 100644 --- a/enterprise/models.py +++ b/enterprise/models.py @@ -411,11 +411,6 @@ class Meta: help_text=_("The email address where learner's reply to enterprise emails will be delivered.") ) - hide_course_price_when_zero = models.BooleanField( - default=False, - help_text=_("Specify whether course cost should be hidden in the landing page when the final price is zero.") - ) - allow_enrollment_in_invite_only_courses = models.BooleanField( default=False, help_text=_( diff --git a/enterprise/utils.py b/enterprise/utils.py index 75288a7fcf..fc1602435d 100644 --- a/enterprise/utils.py +++ b/enterprise/utils.py @@ -2312,31 +2312,6 @@ def logo_path(instance, filename): return fullname -def hide_price_when_zero(enterprise_customer, course_modes): - """ - Adds a "hide_price" flag to the course modes if price is zero and "Hide course price when zero" flag is set. - - Arguments: - enterprise_customer: The EnterpriseCustomer that the enrollemnt is being done. - course_modes: iterable with dictionaries containing a required 'final_price' key - """ - if not enterprise_customer.hide_course_price_when_zero: - return course_modes - - for mode in course_modes: - mode['hide_price'] = False - try: - numbers = re.findall(r'\d+', mode['final_price']) - mode['hide_price'] = int(''.join(numbers)) == 0 - except ValueError: - LOGGER.warning( - 'hide_price_when_zero: Could not convert price "%s" of course mode "%s" to int.', - mode['final_price'], - mode['title'] - ) - return course_modes - - def ensure_course_enrollment_is_allowed(course_id, email, enrollment_api_client): """ Calls the enrollment API to create a CourseEnrollmentAllowed object for diff --git a/enterprise/views.py b/enterprise/views.py index b33a429c6d..590c9a380c 100644 --- a/enterprise/views.py +++ b/enterprise/views.py @@ -77,7 +77,6 @@ get_enterprise_customer_user, get_platform_logo_url, get_program_type_description, - hide_price_when_zero, is_course_run_enrollable, localized_utcnow, track_enrollment, @@ -1553,9 +1552,6 @@ def get_enterprise_course_enrollment_page( # Filter audit course modes. course_modes = filter_audit_course_modes(enterprise_customer, course_modes) - # Set a flag to hide the $0 when the customer doesn't want it to be shown - course_modes = hide_price_when_zero(enterprise_customer, course_modes) - # Allows automatic assignment to a cohort upon enrollment. cohort = request.GET.get('cohort') # Add a message to the message display queue if the learner diff --git a/tests/test_enterprise/test_utils.py b/tests/test_enterprise/test_utils.py index 4fd37cccaa..bf1cee17c1 100644 --- a/tests/test_enterprise/test_utils.py +++ b/tests/test_enterprise/test_utils.py @@ -17,7 +17,6 @@ ensure_course_enrollment_is_allowed, get_idiff_list, get_platform_logo_url, - hide_price_when_zero, is_pending_user, parse_lms_api_datetime, serialize_notification_content, @@ -495,33 +494,6 @@ def expected_email_item(user, activation_links): expected_email_items = [expected_email_item(user, activation_links) for user in users] assert email_items == expected_email_items - @ddt.data(True, False) - def test_hide_course_price_when_zero(self, hide_price): - customer = factories.EnterpriseCustomerFactory() - zero_modes = [ - {"final_price": "$0"}, - {"final_price": "$0.000"}, - {"final_price": "Rs. 0.00"}, - {"final_price": "0.00 EURO"}, - ] - non_zero_modes = [ - {"final_price": "$100"}, - {"final_price": "$73.50"}, - {"final_price": "Rs.8000.00"}, - {"final_price": "4000 Euros"}, - ] - customer.hide_course_price_when_zero = hide_price - - processed_zero_modes = hide_price_when_zero(customer, zero_modes) - processed_non_zero_modes = hide_price_when_zero(customer, non_zero_modes) - - if hide_price: - self.assertTrue(all(mode["hide_price"] for mode in processed_zero_modes)) - self.assertFalse(all(mode["hide_price"] for mode in processed_non_zero_modes)) - else: - self.assertEqual(zero_modes, processed_zero_modes) - self.assertEqual(non_zero_modes, processed_non_zero_modes) - @ddt.data(True, False) def test_ensure_course_enrollment_is_allowed(self, invite_only): """ diff --git a/tests/test_utilities.py b/tests/test_utilities.py index 7bd9affb94..b4a9f69ddd 100644 --- a/tests/test_utilities.py +++ b/tests/test_utilities.py @@ -168,7 +168,6 @@ def setUp(self): "system_wide_role_assignments", "reply_to", "hide_labor_market_data", - "hide_course_price_when_zero", ] ), (