-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added staff role on ccx to staff of master course and added a data mi…
…gration for existing ccx courses.
- Loading branch information
1 parent
6cc8bbf
commit 91bf48f
Showing
7 changed files
with
239 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
lms/djangoapps/ccx/migrations/0002_add_master_course_staff_in_ccx.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from ccx_keys.locator import CCXLocator | ||
from django.db import migrations | ||
|
||
from lms.djangoapps.ccx.models import CustomCourseForEdX | ||
from lms.djangoapps.ccx.utils import ( | ||
add_master_course_staff_to_ccx, | ||
reverse_add_master_course_staff_to_ccx | ||
) | ||
|
||
|
||
def add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor): | ||
""" | ||
Add all staff and admin of master course to respective CCX(s). | ||
""" | ||
list_ccx = CustomCourseForEdX.objects.all() | ||
for ccx in list_ccx: | ||
ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) | ||
add_master_course_staff_to_ccx(ccx.course, ccx_locator, ccx.display_name) | ||
|
||
|
||
def reverse_add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor): | ||
""" | ||
Add all staff and admin of master course to respective CCX(s). | ||
""" | ||
list_ccx = CustomCourseForEdX.objects.all() | ||
for ccx in list_ccx: | ||
ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) | ||
reverse_add_master_course_staff_to_ccx(ccx.course, ccx_locator, ccx.display_name) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ccx', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
add_master_course_staff_to_ccx_for_existing_ccx, | ||
reverse_code=reverse_add_master_course_staff_to_ccx_for_existing_ccx | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters