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
16cc7961
Commit
16cc7961
authored
Mar 07, 2017
by
Vedran Karacic
Committed by
Vedran Karačić
Mar 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration to update enrollment code product class.
parent
b78a6cbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletions
+41
-1
ecommerce/extensions/catalogue/migrations/0024_fix_enrollment_code_slug.py
+40
-0
ecommerce/extensions/catalogue/tests/mixins.py
+1
-1
No files found.
ecommerce/extensions/catalogue/migrations/0024_fix_enrollment_code_slug.py
0 → 100644
View file @
16cc7961
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
from
oscar.core.loading
import
get_model
ProductClass
=
get_model
(
"catalogue"
,
"ProductClass"
)
WRONG_SLUG
=
'enrollment-code'
RIGHT_SLUG
=
'enrollment_code'
def
fix_enrollment_code_slug
(
apps
,
schema_editor
):
"""Update the faulty product class."""
try
:
product_class
=
ProductClass
.
objects
.
get
(
slug
=
WRONG_SLUG
)
product_class
.
slug
=
RIGHT_SLUG
product_class
.
save
()
except
ProductClass
.
DoesNotExist
:
pass
def
revert_migration
(
apps
,
schema_editor
):
try
:
product_class
=
ProductClass
.
objects
.
get
(
slug
=
RIGHT_SLUG
)
product_class
.
slug
=
WRONG_SLUG
product_class
.
save
()
except
ProductClass
.
DoesNotExist
:
pass
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'catalogue'
,
'0001_initial'
),
(
'catalogue'
,
'0023_auto_20170215_2234'
)
]
operations
=
[
migrations
.
RunPython
(
fix_enrollment_code_slug
,
revert_migration
)
]
ecommerce/extensions/catalogue/tests/mixins.py
View file @
16cc7961
...
@@ -110,7 +110,7 @@ class CourseCatalogTestMixin(object):
...
@@ -110,7 +110,7 @@ class CourseCatalogTestMixin(object):
(
'id_verification_required'
,
'boolean'
)
(
'id_verification_required'
,
'boolean'
)
)
)
product_class
=
self
.
_create_product_class
(
product_class
=
self
.
_create_product_class
(
ENROLLMENT_CODE_PRODUCT_CLASS_NAME
,
slugify
(
ENROLLMENT_CODE_PRODUCT_CLASS_NAME
)
,
attributes
ENROLLMENT_CODE_PRODUCT_CLASS_NAME
,
'enrollment_code'
,
attributes
)
)
return
product_class
return
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