Skip to content

Commit

Permalink
Merge pull request #72 from edly-io/rehan/merge-multisite-changes
Browse files Browse the repository at this point in the history
Merge latest develop-multisite changes
  • Loading branch information
rehan99000 authored Mar 11, 2021
2 parents 2b0be9f + f293aa9 commit a0f007d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
11 changes: 10 additions & 1 deletion ecommerce/extensions/api/v2/views/coupons.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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
Expand Down Expand Up @@ -118,10 +119,15 @@ 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)
response_data = self.create_order_for_invoice(
Expand Down Expand Up @@ -449,6 +455,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
Expand Down
2 changes: 2 additions & 0 deletions ecommerce/extensions/edly_ecommerce_app/constants.py
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 20 additions & 3 deletions ecommerce/static/js/views/coupon_form_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,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) {
Expand Down Expand Up @@ -750,8 +753,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();
Expand Down
6 changes: 6 additions & 0 deletions ecommerce/static/js/views/course_form_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,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;
},

Expand Down

0 comments on commit a0f007d

Please sign in to comment.