-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Adds staff and instructor users of the master course to CCX #11787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
macdiesel
merged 1 commit into
openedx:master
from
mitocw:enhancement/aq/add_master_course_staff_in_ccx_fix_migration_issue
Mar 28, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py
This file contains hidden or 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,74 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from __future__ import unicode_literals | ||
|
|
||
| from ccx_keys.locator import CCXLocator | ||
| from courseware.courses import get_course_by_id | ||
| from django.db import migrations | ||
|
|
||
| from lms.djangoapps.ccx.utils import ( | ||
| add_master_course_staff_to_ccx, | ||
| remove_master_course_staff_from_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). | ||
|
|
||
| Arguments: | ||
| apps (Applications): Apps in edX platform. | ||
| schema_editor (SchemaEditor): For editing database schema i.e create, delete field (column) | ||
|
|
||
| """ | ||
| 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. | ||
| 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 | ||
| ) | ||
|
|
||
|
|
||
| def remove_master_course_staff_from_ccx_for_existing_ccx(apps, schema_editor): | ||
| """ | ||
| Remove all staff and instructors of master course from respective CCX(s). | ||
|
|
||
| Arguments: | ||
| apps (Applications): Apps in edX platform. | ||
| schema_editor (SchemaEditor): For editing database schema i.e create, delete field (column) | ||
|
|
||
| """ | ||
| 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. | ||
| 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 | ||
| ) | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('ccx', '0001_initial'), | ||
| ('ccx', '0002_customcourseforedx_structure_json'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython( | ||
| code=add_master_course_staff_to_ccx_for_existing_ccx, | ||
| reverse_code=remove_master_course_staff_from_ccx_for_existing_ccx | ||
| ) | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation for the arguments:
https://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html