diff --git a/ecommerce/extensions/catalogue/migrations/0055_sf_opp_line_item_ent_attr.py b/ecommerce/extensions/catalogue/migrations/0055_sf_opp_line_item_ent_attr.py new file mode 100644 index 00000000000..588e94ed7e2 --- /dev/null +++ b/ecommerce/extensions/catalogue/migrations/0055_sf_opp_line_item_ent_attr.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + + +from django.db import migrations +from oscar.core.loading import get_model + +from ecommerce.core.constants import COUPON_PRODUCT_CLASS_NAME + +ProductAttribute = get_model("catalogue", "ProductAttribute") +ProductClass = get_model("catalogue", "ProductClass") + +SF_LINE_ITEM_ATTRIBUTE_CODE = 'salesforce_opportunity_line_item' + + +def create_sf_opp_line_item_attribute(apps, schema_editor): + """Create enterprise coupon salesforce_opportunity_line_item product attribute.""" + ProductAttribute.skip_history_when_saving = True + coupon = ProductClass.objects.get(name=COUPON_PRODUCT_CLASS_NAME) + pa = ProductAttribute( + product_class=coupon, + name='Salesforce Opportunity Line Item', + code=SF_LINE_ITEM_ATTRIBUTE_CODE, + type='text', + required=True, + ) + pa.save() + + +def remove_sf_opp_line_item_attribute(apps, schema_editor): + """Remove enterprise coupon salesforce_opportunity_line_item product attribute.""" + coupon = ProductClass.objects.get(name=COUPON_PRODUCT_CLASS_NAME) + ProductAttribute.skip_history_when_saving = True + ProductAttribute.objects.get(product_class=coupon, code=SF_LINE_ITEM_ATTRIBUTE_CODE).delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0054_add_variant_id_product_attr') + ] + operations = [ + migrations.RunPython( + create_sf_opp_line_item_attribute, + remove_sf_opp_line_item_attribute, + ), + ] diff --git a/setup.cfg b/setup.cfg index e69362b4b18..10119aebaf5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,3 +6,6 @@ ignore=E501,E722,W504 max_line_length=119 exclude=settings,migrations,ecommerce/static,bower_components,ecommerce/wsgi.py + +[flake8] +max-line-length=119