Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
912db991
Commit
912db991
authored
Aug 07, 2015
by
Brandon DeRosier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CCX 0002 migration
(cherry picked from commit 558b93fdeaaf72d02e050808698b2015e123a01c)
parent
34526ddf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
lms/djangoapps/ccx/migrations/0002_convert_memberships.py
+7
-3
No files found.
lms/djangoapps/ccx/migrations/0002_convert_memberships.py
View file @
912db991
...
...
@@ -3,6 +3,7 @@ from south.utils import datetime_utils as datetime
from
south.db
import
db
from
south.v2
import
DataMigration
from
django.db
import
models
from
opaque_keys
import
InvalidKeyError
class
Migration
(
DataMigration
):
...
...
@@ -12,11 +13,14 @@ class Migration(DataMigration):
memberships
=
orm
[
'ccx.CcxMembership'
]
.
objects
.
select_related
(
'ccx'
,
'student'
)
.
all
()
for
membership
in
memberships
:
ccx
=
membership
.
ccx
course_key
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
ccx
.
id
)
enrollment
,
created
=
orm
[
'student.CourseEnrollment'
]
.
objects
.
get_or_create
(
try
:
course_key
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
ccx
.
id
)
enrollment
,
created
=
orm
[
'student.CourseEnrollment'
]
.
objects
.
get_or_create
(
user
=
membership
.
student
,
course_id
=
course_key
,
)
)
except
InvalidKeyError
:
membership
.
delete
()
def
backwards
(
self
,
orm
):
...
...
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