Commit ecbc5771 by Vedran Karačić

Merge pull request #701 from edx/remove-enrollment-code-migration

Remove enrollment code migration functionality
parents 0c0a56e2 a332dab5
......@@ -3,100 +3,7 @@ from __future__ import unicode_literals
import oscar
from django.db import models, migrations
def create_product_class(apps, schema_editor):
"""
Create a default EnrollmentCode class with added attributes:
- catalog (of courses)
- start date (of validity)
- end date
- type
"""
AttributeOptionGroup = apps.get_model("catalogue", "AttributeOptionGroup")
AttributeOption = apps.get_model("catalogue", "AttributeOption")
Category = apps.get_model("catalogue", "Category")
ProductAttribute = apps.get_model("catalogue", "ProductAttribute")
ProductClass = apps.get_model("catalogue", "ProductClass")
# Create a new product class for enrollment codes
enrollment_code = ProductClass.objects.create(
track_stock=False,
requires_shipping=False,
name='Enrollment code',
slug='enrollment_code',
)
# Create product attributes for enrollment code products
ProductAttribute.objects.create(
product_class=enrollment_code,
name="Catalog",
code="catalog",
type="entity",
required=True
)
ProductAttribute.objects.create(
product_class=enrollment_code,
name="Start date",
code="start_date",
type="date",
required=True
)
ProductAttribute.objects.create(
product_class=enrollment_code,
name="End date",
code="end_date",
type="date",
required=True
)
# Option group for the type of enrollment code.
# single_use - Can be used once by one customer
# multi_use - Can be used multiple times by multiple customers
# once_per_customer - Can only be used once per customer
group = AttributeOptionGroup.objects.create(
name="Type"
)
AttributeOption.objects.create(
group=group,
option='single_use'
)
AttributeOption.objects.create(
group=group,
option='multi_use'
)
AttributeOption.objects.create(
group=group,
option='once_per_customer'
)
ProductAttribute.objects.create(
product_class=enrollment_code,
name="Type",
code="type",
type="option",
option_group=group,
required=True
)
# Create a category for course seats
Category.objects.create(
description="All Enrollment Codes",
numchild=2,
slug="enrollment_codes",
depth=1,
path="0002",
image="",
name="Enrollment Codes"
)
def remove_product_class(apps, schema_editor):
""" Reverse function. """
Category = apps.get_model("catalogue", "Category")
ProductClass = apps.get_model("catalogue", "ProductClass")
Category.objects.filter(slug='enrollment_code').delete()
ProductClass.objects.filter(slug='enrollment_code').delete()
# Depricated. We switched to the Coupon product class.
class Migration(migrations.Migration):
......@@ -105,6 +12,4 @@ class Migration(migrations.Migration):
('catalogue', '0001_initial'),
('catalogue', '0011_auto_20151019_0639')
]
operations = [
migrations.RunPython(create_product_class, remove_product_class)
]
operations = []
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment