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
0d823768
Commit
0d823768
authored
Apr 13, 2016
by
Amir Qayyum Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed exception related to course not found for ccx
parent
173154d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
17 deletions
+37
-17
lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py
+37
-17
No files found.
lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py
View file @
0d823768
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
logging
from
ccx_keys.locator
import
CCXLocator
from
courseware.courses
import
get_course_by_id
from
django.db
import
migrations
from
django.http
import
Http404
from
lms.djangoapps.ccx.utils
import
(
add_master_course_staff_to_ccx
,
remove_master_course_staff_from_ccx
,
)
log
=
logging
.
getLogger
(
"edx.ccx"
)
def
add_master_course_staff_to_ccx_for_existing_ccx
(
apps
,
schema_editor
):
"""
...
...
@@ -23,16 +28,24 @@ def add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor):
CustomCourseForEdX
=
apps
.
get_model
(
"ccx"
,
"CustomCourseForEdX"
)
list_ccx
=
CustomCourseForEdX
.
objects
.
all
()
for
ccx
in
list_ccx
:
if
ccx
.
course_id
.
deprecated
:
# prevent migration for deprecated course ids.
if
not
ccx
.
course_id
or
ccx
.
course_id
.
deprecated
:
# prevent migration for deprecated course ids
or invalid ids
.
continue
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
add_master_course_staff_to_ccx
(
get_course_by_id
(
ccx
.
course_id
),
ccx_locator
,
ccx
.
display_name
,
send_email
=
False
)
try
:
course
=
get_course_by_id
(
ccx
.
course_id
)
add_master_course_staff_to_ccx
(
course
,
ccx_locator
,
ccx
.
display_name
,
send_email
=
False
)
except
Http404
:
log
.
warning
(
"Unable to add instructors and staff of master course
%
s to ccx
%
s."
,
ccx
.
course_id
,
ccx_locator
)
def
remove_master_course_staff_from_ccx_for_existing_ccx
(
apps
,
schema_editor
):
...
...
@@ -47,17 +60,24 @@ def remove_master_course_staff_from_ccx_for_existing_ccx(apps, schema_editor):
CustomCourseForEdX
=
apps
.
get_model
(
"ccx"
,
"CustomCourseForEdX"
)
list_ccx
=
CustomCourseForEdX
.
objects
.
all
()
for
ccx
in
list_ccx
:
if
ccx
.
course_id
.
deprecated
:
# prevent migration for deprecated course ids.
if
not
ccx
.
course_id
or
ccx
.
course_id
.
deprecated
:
# prevent migration for deprecated course ids
or invalid ids
.
continue
ccx_locator
=
CCXLocator
.
from_course_locator
(
ccx
.
course_id
,
unicode
(
ccx
.
id
))
remove_master_course_staff_from_ccx
(
get_course_by_id
(
ccx
.
course_id
),
ccx_locator
,
ccx
.
display_name
,
send_email
=
False
)
try
:
course
=
get_course_by_id
(
ccx
.
course_id
)
remove_master_course_staff_from_ccx
(
course
,
ccx_locator
,
ccx
.
display_name
,
send_email
=
False
)
except
Http404
:
log
.
warning
(
"Unable to remove instructors and staff of master course
%
s from ccx
%
s."
,
ccx
.
course_id
,
ccx_locator
)
class
Migration
(
migrations
.
Migration
):
...
...
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