From a8cb793cd593b0ec0ec0c4a0da61ba201325191f Mon Sep 17 00:00:00 2001 From: Taimoor Ahmed <68893403+taimoor-ahmed-1@users.noreply.github.com> Date: Tue, 23 Feb 2021 11:03:50 +0500 Subject: [PATCH 1/2] Hide credit mode in course modes - EDLY-2634 (#68) --- ecommerce/static/js/views/course_form_view.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ecommerce/static/js/views/course_form_view.js b/ecommerce/static/js/views/course_form_view.js index ab6f5187993..c1e16d1eeed 100644 --- a/ecommerce/static/js/views/course_form_view.js +++ b/ecommerce/static/js/views/course_form_view.js @@ -208,6 +208,12 @@ define([ this.stickit(); this._super(); + if (!window.waffle.SWITCHES['enable_non_edly_cloud_options_switch']) { + const courseTypeCredit = this.$('#courseTypecredit'); + courseTypeCredit.attr('disabled', true); + courseTypeCredit.parent().parent().addClass('hidden'); + } + return this; }, From 7eff4cb2772d76d2c364aa8259930e341491b501 Mon Sep 17 00:00:00 2001 From: Taimoor Ahmed <68893403+taimoor-ahmed-1@users.noreply.github.com> Date: Tue, 2 Mar 2021 12:23:06 +0500 Subject: [PATCH 2/2] Hide non edly coupon options - EDLY-2643 (#69) --- ecommerce/extensions/api/v2/views/coupons.py | 10 +++++++- .../edly_ecommerce_app/constants.py | 2 ++ ecommerce/static/js/views/coupon_form_view.js | 23 ++++++++++++++++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 ecommerce/extensions/edly_ecommerce_app/constants.py diff --git a/ecommerce/extensions/api/v2/views/coupons.py b/ecommerce/extensions/api/v2/views/coupons.py index 55ffde66126..2e8a382d1b6 100644 --- a/ecommerce/extensions/api/v2/views/coupons.py +++ b/ecommerce/extensions/api/v2/views/coupons.py @@ -25,6 +25,7 @@ from ecommerce.extensions.basket.utils import prepare_basket from ecommerce.extensions.catalogue.utils import create_coupon_product, get_or_create_catalog from ecommerce.extensions.checkout.mixins import EdxOrderPlacementMixin +from ecommerce.extensions.edly_ecommerce_app.constants import ENABLE_NON_EDLY_CLOUD_OPTIONS_SWITCH from ecommerce.extensions.edly_ecommerce_app.permissions import IsAdminOrCourseCreator from ecommerce.extensions.payment.processors.invoice import InvoicePayment from ecommerce.extensions.voucher.models import CouponVouchers @@ -117,10 +118,14 @@ def create(self, request, *args, **kwargs): return Response(str(error), status=status.HTTP_400_BAD_REQUEST) basket = prepare_basket(request, [coupon_product]) + if waffle.switch_is_active(ENABLE_NON_EDLY_CLOUD_OPTIONS_SWITCH): + client_username = request.data.get('client') + else: + client_username = request.site.siteconfiguration.partner.short_code # Create an order now since payment is handled out of band via an invoice. client, __ = BusinessClient.objects.update_or_create( - name=cleaned_voucher_data['enterprise_customer_name'] or request.data.get('client'), + name=cleaned_voucher_data['enterprise_customer_name'] or client_username, defaults={'enterprise_customer_uuid': cleaned_voucher_data['enterprise_customer']} ) invoice_data = self.create_update_data_dict(data=request.data, fields=Invoice.UPDATEABLE_INVOICE_FIELDS) @@ -445,6 +450,9 @@ def update_coupon_product_data(self, request_data, coupon): ProductCategory.objects.filter(product=coupon).update(category=category) client_username = request_data.get('client') + if not waffle.switch_is_active(ENABLE_NON_EDLY_CLOUD_OPTIONS_SWITCH): + client_username = self.request.site.siteconfiguration.partner.short_code + enterprise_customer_data = request_data.get('enterprise_customer') enterprise_customer = enterprise_customer_data.get('id', None) if enterprise_customer_data else None enterprise_customer_name = enterprise_customer_data.get('name', None) if enterprise_customer_data else None diff --git a/ecommerce/extensions/edly_ecommerce_app/constants.py b/ecommerce/extensions/edly_ecommerce_app/constants.py new file mode 100644 index 00000000000..eaa8e94deb0 --- /dev/null +++ b/ecommerce/extensions/edly_ecommerce_app/constants.py @@ -0,0 +1,2 @@ +# Waffle switch used to enable/disable non-edly cloud options. +ENABLE_NON_EDLY_CLOUD_OPTIONS_SWITCH = 'enable_non_edly_cloud_options_switch' diff --git a/ecommerce/static/js/views/coupon_form_view.js b/ecommerce/static/js/views/coupon_form_view.js index c8833453aea..57ed8634d61 100644 --- a/ecommerce/static/js/views/coupon_form_view.js +++ b/ecommerce/static/js/views/coupon_form_view.js @@ -548,7 +548,10 @@ define([ if (catalogType === this.model.catalogTypes.single_course) { this.toggleMultiCourseRelatedFields(true); this.toggleCourseCatalogRelatedFields(true); - this.toggleEnterpriseRelatedFields(false); + if (window.waffle.SWITCHES['enable_non_edly_cloud_options_switch']) { + this.toggleEnterpriseRelatedFields(false); + } + this.toggleProgramRelatedFields(true); this.toggleSingleCourseRealtedFields(false); } else if (catalogType === this.model.catalogTypes.catalog) { @@ -760,8 +763,22 @@ define([ } else { this.toggleEnterpriseRelatedFields(true); this.toggleCourseCatalogRelatedFields(true); - this.$('.catalog-type input').attr('disabled', true); - this.$('.catalog-type').parent().addClass('hidden'); + + const multipleCoursesInput = this.$('#multiple-courses'); + multipleCoursesInput.attr('disabled', true); + multipleCoursesInput.addClass('hidden'); + multipleCoursesInput.next().addClass('hidden'); + + const catalogInput = this.$('#catalog'); + catalogInput.attr('disabled', true); + catalogInput.addClass('hidden'); + catalogInput.next().addClass('hidden'); + + const emailDomainInput = this.$('#email-domains'); + emailDomainInput.attr('disabled', true); + emailDomainInput.parent().addClass('hidden'); + + this.hideField('#client', '#'); } this.dynamic_catalog_view.setElement(this.$('.catalog_buttons')).render();