This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add variant_id to seat info for ExecEd courses (#4084)
- Loading branch information
1 parent
1a8335a
commit b2dbca2
Showing
5 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ecommerce/extensions/catalogue/migrations/0056_add_variant_id_seat_product_attr.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 3.2.20 on 2024-01-04 09:32 | ||
|
||
from django.db import migrations | ||
|
||
from ecommerce.core.constants import SEAT_PRODUCT_CLASS_NAME | ||
|
||
|
||
def create_product_attribute(apps, schema_editor): | ||
""" Create a product attribute for course seat product class""" | ||
ProductAttribute = apps.get_model("catalogue", "ProductAttribute") | ||
ProductClass = apps.get_model("catalogue", "ProductClass") | ||
|
||
for class_iter in (ProductAttribute, ProductClass): | ||
class_iter.skip_history_when_saving = True | ||
|
||
seat = ProductClass.objects.get(name=SEAT_PRODUCT_CLASS_NAME) | ||
|
||
# Create product attribute for course seat products | ||
product_attr = ProductAttribute( | ||
product_class=seat, | ||
name="variant_id", | ||
code="variant_id", | ||
type="text", | ||
required=False | ||
) | ||
product_attr.save() | ||
|
||
def remove_product_attribute(apps, schema_editor): | ||
""" Reverse function. """ | ||
ProductAttribute = apps.get_model("catalogue", "ProductAttribute") | ||
ProductAttribute.skip_history_when_saving = True | ||
ProductAttribute.objects.filter(name='variant_id', product_class__name=SEAT_PRODUCT_CLASS_NAME).delete() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalogue', '0055_sf_opp_line_item_ent_attr'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(create_product_attribute, remove_product_attribute), | ||
] |