From d3d6272d8f2aa5a955c6faccf236efb070d7f818 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Fri, 5 Jan 2018 16:27:51 -0500 Subject: [PATCH] PLAT-1873 to_deprecated_string() cleanup part 1 --- cms/djangoapps/contentstore/config/forms.py | 3 +- cms/djangoapps/contentstore/config/models.py | 3 +- cms/djangoapps/contentstore/utils.py | 5 +- cms/templates/widgets/metadata-edit.html | 3 +- cms/templates/widgets/source-edit.html | 3 +- common/djangoapps/course_modes/views.py | 3 +- .../django_comment_common/models.py | 3 +- common/djangoapps/static_replace/__init__.py | 3 +- common/djangoapps/student/models.py | 11 +- common/djangoapps/student/tests/test_login.py | 5 +- common/djangoapps/student/tests/tests.py | 13 +- common/djangoapps/student/views.py | 3 +- common/djangoapps/track/contexts.py | 3 +- common/lib/capa/capa/responsetypes.py | 3 +- common/lib/capa/capa/tests/helpers.py | 12 +- .../capa/tests/test_hint_functionality.py | 12 +- common/lib/xmodule/xmodule/capa_base.py | 25 +- .../lib/xmodule/xmodule/conditional_module.py | 5 +- .../xmodule/xmodule/library_content_module.py | 3 +- common/lib/xmodule/xmodule/lti_module.py | 7 +- common/lib/xmodule/xmodule/seq_module.py | 5 +- .../lib/xmodule/xmodule/split_test_module.py | 9 +- common/lib/xmodule/xmodule/tabs.py | 7 +- .../xmodule/xmodule/tests/test_capa_module.py | 12 +- lms/djangoapps/bulk_email/forms.py | 3 +- lms/djangoapps/bulk_email/models.py | 3 +- lms/djangoapps/bulk_email/tasks.py | 3 +- .../bulk_email/tests/test_course_optout.py | 13 +- .../class_dashboard/dashboard_data.py | 7 +- lms/djangoapps/course_wiki/middleware.py | 9 +- lms/djangoapps/courseware/access.py | 3 +- lms/djangoapps/courseware/courses.py | 5 +- lms/djangoapps/courseware/models.py | 3 +- lms/djangoapps/courseware/module_render.py | 13 +- lms/djangoapps/dashboard/sysadmin.py | 9 +- lms/djangoapps/django_comment_client/utils.py | 7 +- lms/djangoapps/instructor/enrollment.py | 7 +- lms/djangoapps/instructor/tests/test_api.py | 323 +++++++++--------- lms/djangoapps/instructor_analytics/basic.py | 9 +- lms/djangoapps/instructor_task/api_helper.py | 17 +- lms/djangoapps/instructor_task/models.py | 3 +- lms/djangoapps/lms_migration/migrate.py | 3 +- lms/djangoapps/notes/models.py | 3 +- lms/djangoapps/notes/tests.py | 3 +- lms/djangoapps/shoppingcart/models.py | 5 +- lms/djangoapps/shoppingcart/reports.py | 3 +- lms/djangoapps/staticbook/tests.py | 3 +- lms/lib/comment_client/user.py | 8 +- .../class_dashboard/all_section_metrics.js | 5 +- lms/templates/conditional_module.html | 5 +- lms/templates/course.html | 3 +- lms/templates/courseware/course_about.html | 5 +- .../course_about_sidebar_header.html | 5 +- lms/templates/courseware/gradebook.html | 3 +- lms/templates/courseware/progress.html | 3 +- .../header/navbar-not-authenticated.html | 5 +- .../navigation/navbar-not-authenticated.html | 5 +- .../registration_code_receipt.html | 3 +- lms/templates/staff_problem_info.html | 3 +- lms/tests.py | 3 +- openedx/core/lib/courses.py | 3 +- .../test_crowdsource_hinter.py | 8 +- .../xblock_integration/test_recommender.py | 7 +- 63 files changed, 386 insertions(+), 306 deletions(-) diff --git a/cms/djangoapps/contentstore/config/forms.py b/cms/djangoapps/contentstore/config/forms.py index a0c39e2fbc..b233e4f498 100644 --- a/cms/djangoapps/contentstore/config/forms.py +++ b/cms/djangoapps/contentstore/config/forms.py @@ -8,6 +8,7 @@ from django import forms from contentstore.config.models import CourseNewAssetsPageFlag from opaque_keys import InvalidKeyError +from six import text_type from xmodule.modulestore.django import modulestore from opaque_keys.edx.locator import CourseLocator @@ -31,7 +32,7 @@ class CourseNewAssetsPageAdminForm(forms.ModelForm): raise forms.ValidationError(msg) if not modulestore().has_course(course_key): - msg = u'Course not found. Entered course id was: "{0}". '.format(course_key.to_deprecated_string()) + msg = u'Course not found. Entered course id was: "{0}". '.format(text_type(course_key)) raise forms.ValidationError(msg) return course_key diff --git a/cms/djangoapps/contentstore/config/models.py b/cms/djangoapps/contentstore/config/models.py index 7ca42ea726..ace57e0a77 100644 --- a/cms/djangoapps/contentstore/config/models.py +++ b/cms/djangoapps/contentstore/config/models.py @@ -4,6 +4,7 @@ controlling the new assets page. """ from config_models.models import ConfigurationModel from django.db.models import BooleanField +from six import text_type from openedx.core.djangoapps.xmodule_django.models import CourseKeyField @@ -74,4 +75,4 @@ class CourseNewAssetsPageFlag(ConfigurationModel): if self.enabled: not_en = "" # pylint: disable=no-member - return u"Course '{}': New assets page {}Enabled".format(self.course_id.to_deprecated_string(), not_en) + return u"Course '{}': New assets page {}Enabled".format(text_type(self.course_id), not_en) diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 72a17b051e..d13768929a 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -10,6 +10,7 @@ from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from opaque_keys.edx.keys import CourseKey, UsageKey from pytz import UTC +from six import text_type from django_comment_common.models import assign_default_role from django_comment_common.utils import seed_permissions_roles @@ -126,8 +127,8 @@ def get_lms_link_for_item(location, preview=False): return u"//{lms_base}/courses/{course_key}/jump_to/{location}".format( lms_base=lms_base, - course_key=location.course_key.to_deprecated_string(), - location=location.to_deprecated_string(), + course_key=text_type(location.course_key), + location=text_type(location), ) diff --git a/cms/templates/widgets/metadata-edit.html b/cms/templates/widgets/metadata-edit.html index 673038f1da..ad53db6ccf 100644 --- a/cms/templates/widgets/metadata-edit.html +++ b/cms/templates/widgets/metadata-edit.html @@ -5,8 +5,9 @@ import hashlib import copy import json + from six import text_type from xmodule.modulestore import EdxJSONEncoder - hlskey = hashlib.md5(module.location.to_deprecated_string().encode('utf-8')).hexdigest() + hlskey = hashlib.md5(text_type(module.location).encode('utf-8')).hexdigest() %> ## js templates diff --git a/cms/templates/widgets/source-edit.html b/cms/templates/widgets/source-edit.html index 6998193a31..ac58fe9ceb 100644 --- a/cms/templates/widgets/source-edit.html +++ b/cms/templates/widgets/source-edit.html @@ -1,6 +1,7 @@ <% import hashlib - hlskey = hashlib.md5(module.location.to_deprecated_string()).hexdigest() + from six import text_type + hlskey = hashlib.md5(text_type(module.location)).hexdigest() %>