diff --git a/lms/djangoapps/ccx/migrations/0001_initial.py b/lms/djangoapps/ccx/migrations/0001_initial.py index e3d54d7a3d..423894b988 100644 --- a/lms/djangoapps/ccx/migrations/0001_initial.py +++ b/lms/djangoapps/ccx/migrations/0001_initial.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals -from django.db import migrations, models from django.conf import settings +from django.db import migrations, models from opaque_keys.edx.django.models import CourseKeyField, UsageKeyField diff --git a/lms/djangoapps/ccx/migrations/0002_customcourseforedx_structure_json.py b/lms/djangoapps/ccx/migrations/0002_customcourseforedx_structure_json.py index 0ca713e4a5..b63c7df140 100644 --- a/lms/djangoapps/ccx/migrations/0002_customcourseforedx_structure_json.py +++ b/lms/djangoapps/ccx/migrations/0002_customcourseforedx_structure_json.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.db import migrations, models diff --git a/lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py b/lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py index 977a69b5b8..46da286f64 100644 --- a/lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py +++ b/lms/djangoapps/ccx/migrations/0003_add_master_course_staff_in_ccx.py @@ -1,17 +1,15 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import logging +import six 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, -) +from courseware.courses import get_course_by_id +from lms.djangoapps.ccx.utils import add_master_course_staff_to_ccx, remove_master_course_staff_from_ccx log = logging.getLogger("edx.ccx") @@ -31,7 +29,7 @@ def add_master_course_staff_to_ccx_for_existing_ccx(apps, schema_editor): 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)) + ccx_locator = CCXLocator.from_course_locator(ccx.course_id, six.text_type(ccx.id)) try: course = get_course_by_id(ccx.course_id) add_master_course_staff_to_ccx( @@ -63,7 +61,7 @@ def remove_master_course_staff_from_ccx_for_existing_ccx(apps, schema_editor): 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)) + ccx_locator = CCXLocator.from_course_locator(ccx.course_id, six.text_type(ccx.id)) try: course = get_course_by_id(ccx.course_id) remove_master_course_staff_from_ccx( diff --git a/lms/djangoapps/ccx/migrations/0004_seed_forum_roles_in_ccx_courses.py b/lms/djangoapps/ccx/migrations/0004_seed_forum_roles_in_ccx_courses.py index 41d526301b..c67e28ee51 100644 --- a/lms/djangoapps/ccx/migrations/0004_seed_forum_roles_in_ccx_courses.py +++ b/lms/djangoapps/ccx/migrations/0004_seed_forum_roles_in_ccx_courses.py @@ -1,17 +1,25 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import logging +import six 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 openedx.core.djangoapps.django_comment_common.models import FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_MODERATOR, \ - FORUM_ROLE_COMMUNITY_TA, FORUM_ROLE_STUDENT -from openedx.core.djangoapps.django_comment_common.utils import STUDENT_ROLE_PERMISSIONS, MODERATOR_ROLE_PERMISSIONS, \ - ADMINISTRATOR_ROLE_PERMISSIONS +from courseware.courses import get_course_by_id +from openedx.core.djangoapps.django_comment_common.models import ( + FORUM_ROLE_ADMINISTRATOR, + FORUM_ROLE_COMMUNITY_TA, + FORUM_ROLE_MODERATOR, + FORUM_ROLE_STUDENT +) +from openedx.core.djangoapps.django_comment_common.utils import ( + ADMINISTRATOR_ROLE_PERMISSIONS, + MODERATOR_ROLE_PERMISSIONS, + STUDENT_ROLE_PERMISSIONS +) log = logging.getLogger("edx.ccx") @@ -44,7 +52,7 @@ def seed_forum_roles_for_existing_ccx(apps, schema_editor): ) continue - ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) + ccx_locator = CCXLocator.from_course_locator(ccx.course_id, six.text_type(ccx.id)) # Create forum roles. admin_role, _ = Role.objects.get_or_create(name=FORUM_ROLE_ADMINISTRATOR, course_id=ccx_locator) diff --git a/lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py b/lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py index 64fb547554..66191f9145 100644 --- a/lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py +++ b/lms/djangoapps/ccx/migrations/0005_change_ccx_coach_to_staff.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals + import logging +import six +from ccx_keys.locator import CCXLocator from django.contrib.auth.models import User from django.db import migrations from django.http import Http404 -from ccx_keys.locator import CCXLocator from courseware.courses import get_course_by_id from instructor.access import allow_access, revoke_access - log = logging.getLogger("edx.ccx") def change_existing_ccx_coaches_to_staff(apps, schema_editor): @@ -31,18 +32,18 @@ def change_existing_ccx_coaches_to_staff(apps, schema_editor): return list_ccx = CustomCourseForEdX.objects.using(db_alias).all() for ccx in list_ccx: - ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) + ccx_locator = CCXLocator.from_course_locator(ccx.course_id, six.text_type(ccx.id)) try: course = get_course_by_id(ccx_locator) except Http404: - log.error('Could not migrate access for CCX course: %s', unicode(ccx_locator)) + log.error('Could not migrate access for CCX course: %s', six.text_type(ccx_locator)) else: coach = User.objects.get(id=ccx.coach.id) allow_access(course, coach, 'staff', send_email=False) revoke_access(course, coach, 'ccx_coach', send_email=False) log.info( 'The CCX coach of CCX %s has been switched from "CCX Coach" to "Staff".', - unicode(ccx_locator) + six.text_type(ccx_locator) ) def revert_ccx_staff_to_coaches(apps, schema_editor): @@ -61,18 +62,18 @@ def revert_ccx_staff_to_coaches(apps, schema_editor): return list_ccx = CustomCourseForEdX.objects.using(db_alias).all() for ccx in list_ccx: - ccx_locator = CCXLocator.from_course_locator(ccx.course_id, unicode(ccx.id)) + ccx_locator = CCXLocator.from_course_locator(ccx.course_id, six.text_type(ccx.id)) try: course = get_course_by_id(ccx_locator) except Http404: - log.error('Could not migrate access for CCX course: %s', unicode(ccx_locator)) + log.error('Could not migrate access for CCX course: %s', six.text_type(ccx_locator)) else: coach = User.objects.get(id=ccx.coach.id) allow_access(course, coach, 'ccx_coach', send_email=False) revoke_access(course, coach, 'staff', send_email=False) log.info( 'The CCX coach of CCX %s has been switched from "Staff" to "CCX Coach".', - unicode(ccx_locator) + six.text_type(ccx_locator) ) class Migration(migrations.Migration): diff --git a/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py b/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py index ff7ca5d64e..4fd5d62fdf 100644 --- a/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py +++ b/lms/djangoapps/ccx/migrations/0006_set_display_name_as_override.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.15 on 2018-08-31 18:13 -from __future__ import unicode_literals - -from django.db import migrations -from django.http import Http404 +from __future__ import absolute_import, unicode_literals import json import logging from ccx_keys.locator import CCXLocator +from django.db import migrations +from django.http import Http404 + from courseware.courses import get_course_by_id log = logging.getLogger(__name__)