From bdb1e61b82280b30a33fb64192da381a9d715b2c Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 27 Jul 2021 23:35:00 +0500 Subject: [PATCH] chore: Django3 has removed python_2_unicode_compatible. Execute the codemodes. --- lms/djangoapps/certificates/models.py | 6 +----- lms/djangoapps/commerce/models.py | 3 +-- lms/djangoapps/grades/config/models.py | 4 +--- lms/djangoapps/grades/course_data.py | 3 --- lms/djangoapps/grades/models.py | 6 +----- lms/djangoapps/instructor_task/models.py | 3 +-- 6 files changed, 5 insertions(+), 20 deletions(-) diff --git a/lms/djangoapps/certificates/models.py b/lms/djangoapps/certificates/models.py index a095762ec9..0c5dc49829 100644 --- a/lms/djangoapps/certificates/models.py +++ b/lms/djangoapps/certificates/models.py @@ -16,7 +16,7 @@ from django.core.exceptions import ValidationError from django.db import models, transaction from django.db.models import Count from django.dispatch import receiver -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext_lazy as _ from model_utils import Choices from model_utils.fields import AutoCreatedField @@ -438,7 +438,6 @@ class GeneratedCertificate(models.Model): ) -@python_2_unicode_compatible class CertificateGenerationHistory(TimeStampedModel): """ Model for storing Certificate Generation History. @@ -503,7 +502,6 @@ class CertificateGenerationHistory(TimeStampedModel): ("regenerated" if self.is_regeneration else "generated", self.generated_by, self.created, self.course_id) -@python_2_unicode_compatible class CertificateInvalidation(TimeStampedModel): """ Model for storing Certificate Invalidation. @@ -1014,7 +1012,6 @@ class CertificateHtmlViewConfiguration(ConfigurationModel): return json_data -@python_2_unicode_compatible class CertificateTemplate(TimeStampedModel): """A set of custom web certificate templates. @@ -1095,7 +1092,6 @@ def template_assets_path(instance, filename): return name -@python_2_unicode_compatible class CertificateTemplateAsset(TimeStampedModel): """A set of assets to be used in custom web certificate templates. diff --git a/lms/djangoapps/commerce/models.py b/lms/djangoapps/commerce/models.py index b425c1d251..ca5f98656b 100644 --- a/lms/djangoapps/commerce/models.py +++ b/lms/djangoapps/commerce/models.py @@ -5,11 +5,10 @@ Commerce-related models. from config_models.models import ConfigurationModel from django.db import models -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext_lazy as _ -@python_2_unicode_compatible class CommerceConfiguration(ConfigurationModel): """ Commerce configuration diff --git a/lms/djangoapps/grades/config/models.py b/lms/djangoapps/grades/config/models.py index 4d83c30496..938654bfd4 100644 --- a/lms/djangoapps/grades/config/models.py +++ b/lms/djangoapps/grades/config/models.py @@ -7,13 +7,12 @@ controlling persistent grades. from config_models.models import ConfigurationModel from django.conf import settings from django.db.models import BooleanField, IntegerField, TextField -from django.utils.encoding import python_2_unicode_compatible + from opaque_keys.edx.django.models import CourseKeyField from openedx.core.lib.cache_utils import request_cached -@python_2_unicode_compatible class PersistentGradesEnabledFlag(ConfigurationModel): """ Enables persistent grades across the platform. @@ -71,7 +70,6 @@ class PersistentGradesEnabledFlag(ConfigurationModel): ) -@python_2_unicode_compatible class CoursePersistentGradesFlag(ConfigurationModel): """ Enables persistent grades for a specific diff --git a/lms/djangoapps/grades/course_data.py b/lms/djangoapps/grades/course_data.py index 96e137355a..06f50f127b 100644 --- a/lms/djangoapps/grades/course_data.py +++ b/lms/djangoapps/grades/course_data.py @@ -3,8 +3,6 @@ Code used to get and cache the requested course-data """ -from django.utils.encoding import python_2_unicode_compatible - from lms.djangoapps.course_blocks.api import get_course_blocks from openedx.core.djangoapps.content.block_structure.api import get_block_structure_manager from xmodule.modulestore.django import modulestore @@ -12,7 +10,6 @@ from xmodule.modulestore.django import modulestore from .transformer import GradesTransformer -@python_2_unicode_compatible class CourseData: """ Utility access layer to intelligently get and cache the diff --git a/lms/djangoapps/grades/models.py b/lms/djangoapps/grades/models.py index 346d5947cb..e92bec8830 100644 --- a/lms/djangoapps/grades/models.py +++ b/lms/djangoapps/grades/models.py @@ -17,7 +17,7 @@ from hashlib import sha1 from django.apps import apps from django.db import models, IntegrityError, transaction -from django.utils.encoding import python_2_unicode_compatible + from django.utils.timezone import now from lazy import lazy from model_utils.models import TimeStampedModel @@ -125,7 +125,6 @@ class BlockRecordList: return cls(blocks, course_key) -@python_2_unicode_compatible class VisibleBlocks(models.Model): """ A django model used to track the state of a set of visible blocks under a @@ -290,7 +289,6 @@ class VisibleBlocks(models.Model): return f"visible_blocks_cache.{course_key}.{user_id}" -@python_2_unicode_compatible class PersistentSubsectionGrade(TimeStampedModel): """ A django model tracking persistent grades at the subsection level. @@ -533,7 +531,6 @@ class PersistentSubsectionGrade(TimeStampedModel): return f"subsection_grades_cache.{course_id}" -@python_2_unicode_compatible class PersistentCourseGrade(TimeStampedModel): """ A django model tracking persistent course grades. @@ -670,7 +667,6 @@ class PersistentCourseGrade(TimeStampedModel): events.course_grade_calculated(grade) -@python_2_unicode_compatible class PersistentSubsectionGradeOverride(models.Model): """ A django model tracking persistent grades overrides at the subsection level. diff --git a/lms/djangoapps/instructor_task/models.py b/lms/djangoapps/instructor_task/models.py index 7b277a3135..10f178a3b7 100644 --- a/lms/djangoapps/instructor_task/models.py +++ b/lms/djangoapps/instructor_task/models.py @@ -24,7 +24,7 @@ from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.files.base import ContentFile from django.db import models, transaction -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext as _ from opaque_keys.edx.django.models import CourseKeyField @@ -38,7 +38,6 @@ PROGRESS = 'PROGRESS' TASK_INPUT_LENGTH = 10000 -@python_2_unicode_compatible class InstructorTask(models.Model): """ Stores information about background tasks that have been submitted to