Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
a332dab5
Commit
a332dab5
authored
Apr 28, 2016
by
Vedran Karacic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove enrollment code migration functionality
parent
0c0a56e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
97 deletions
+2
-97
ecommerce/extensions/catalogue/migrations/0012_enrollment_code_product_class.py
+2
-97
No files found.
ecommerce/extensions/catalogue/migrations/0012_enrollment_code_product_class.py
View file @
a332dab5
...
@@ -3,100 +3,7 @@ from __future__ import unicode_literals
...
@@ -3,100 +3,7 @@ from __future__ import unicode_literals
import
oscar
import
oscar
from
django.db
import
models
,
migrations
from
django.db
import
models
,
migrations
# Depricated. We switched to the Coupon product class.
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
()
class
Migration
(
migrations
.
Migration
):
class
Migration
(
migrations
.
Migration
):
...
@@ -105,6 +12,4 @@ class Migration(migrations.Migration):
...
@@ -105,6 +12,4 @@ class Migration(migrations.Migration):
(
'catalogue'
,
'0001_initial'
),
(
'catalogue'
,
'0001_initial'
),
(
'catalogue'
,
'0011_auto_20151019_0639'
)
(
'catalogue'
,
'0011_auto_20151019_0639'
)
]
]
operations
=
[
operations
=
[]
migrations
.
RunPython
(
create_product_class
,
remove_product_class
)
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment