From 1f12ab186ca5967835e23f3bac5d4f1ba7b719e5 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 29 Jul 2021 18:22:22 +0500 Subject: [PATCH 1/2] chore: Django3 has removed python_2_unicode_compatible. Execute the codemodes. --- openedx/core/djangoapps/content/block_structure/store.py | 2 -- openedx/core/djangoapps/safe_sessions/middleware.py | 3 +-- openedx/core/djangoapps/util/user_utils.py | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/openedx/core/djangoapps/content/block_structure/store.py b/openedx/core/djangoapps/content/block_structure/store.py index 1630150e6a..2342079bdc 100644 --- a/openedx/core/djangoapps/content/block_structure/store.py +++ b/openedx/core/djangoapps/content/block_structure/store.py @@ -6,7 +6,6 @@ Module for the Storage of BlockStructure objects. from logging import getLogger -from django.utils.encoding import python_2_unicode_compatible from openedx.core.lib.cache_utils import zpickle, zunpickle @@ -20,7 +19,6 @@ from .transformer_registry import TransformerRegistry logger = getLogger(__name__) # pylint: disable=C0103 -@python_2_unicode_compatible class StubModel: """ Stub model to use when storage backing is disabled. diff --git a/openedx/core/djangoapps/safe_sessions/middleware.py b/openedx/core/djangoapps/safe_sessions/middleware.py index 1f8e07166c..9031598036 100644 --- a/openedx/core/djangoapps/safe_sessions/middleware.py +++ b/openedx/core/djangoapps/safe_sessions/middleware.py @@ -78,7 +78,7 @@ from django.core import signing from django.http import HttpResponse from django.utils.crypto import get_random_string from django.utils.deprecation import MiddlewareMixin -from django.utils.encoding import python_2_unicode_compatible + from edx_django_utils.monitoring import set_custom_attribute from openedx.core.lib.mobile_utils import is_request_from_mobile_app @@ -106,7 +106,6 @@ class SafeCookieError(Exception): log.error(error_message) -@python_2_unicode_compatible class SafeCookieData: """ Cookie data that cryptographically binds and timestamps the user diff --git a/openedx/core/djangoapps/util/user_utils.py b/openedx/core/djangoapps/util/user_utils.py index e41e94a417..90bc1b1376 100644 --- a/openedx/core/djangoapps/util/user_utils.py +++ b/openedx/core/djangoapps/util/user_utils.py @@ -2,12 +2,9 @@ Custom user-related utility code. """ - -from django.utils.encoding import python_2_unicode_compatible from django.contrib.auth.models import AnonymousUser -@python_2_unicode_compatible class SystemUser(AnonymousUser): """ A User that can act on behalf of system actions, when a user object is From 82ef28b43fe11f87f8e0fc058e95b07e43d41ed6 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 29 Jul 2021 18:24:39 +0500 Subject: [PATCH 2/2] chore: Django3 has removed python_2_unicode_compatible. Execute the codemodes. --- openedx/features/announcements/models.py | 2 -- openedx/features/content_type_gating/models.py | 3 +-- openedx/features/course_duration_limits/models.py | 3 +-- openedx/features/discounts/models.py | 4 +--- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/openedx/features/announcements/models.py b/openedx/features/announcements/models.py index 71aab7963a..cb202ce521 100644 --- a/openedx/features/announcements/models.py +++ b/openedx/features/announcements/models.py @@ -4,10 +4,8 @@ Models for Announcements from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Announcement(models.Model): """Site-wide announcements to be displayed on the dashboard""" class Meta: diff --git a/openedx/features/content_type_gating/models.py b/openedx/features/content_type_gating/models.py index 726786e23c..1dde8b9348 100644 --- a/openedx/features/content_type_gating/models.py +++ b/openedx/features/content_type_gating/models.py @@ -5,14 +5,13 @@ Content Type Gating Configuration Models from django.core.exceptions import ValidationError from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext_lazy as _ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurationModel from openedx.features.content_type_gating.helpers import correct_modes_for_fbe, enrollment_date_for_fbe -@python_2_unicode_compatible class ContentTypeGatingConfig(StackedConfigurationModel): """ A ConfigurationModel used to manage configuration for Content Type Gating (Feature Based Enrollments). diff --git a/openedx/features/course_duration_limits/models.py b/openedx/features/course_duration_limits/models.py index 70a46031d6..fe1d0cb589 100644 --- a/openedx/features/course_duration_limits/models.py +++ b/openedx/features/course_duration_limits/models.py @@ -5,14 +5,13 @@ Course Duration Limit Configuration Models from django.core.exceptions import ValidationError from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext_lazy as _ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurationModel from openedx.features.content_type_gating.helpers import correct_modes_for_fbe, enrollment_date_for_fbe -@python_2_unicode_compatible class CourseDurationLimitConfig(StackedConfigurationModel): """ Configuration to manage the Course Duration Limit facility. diff --git a/openedx/features/discounts/models.py b/openedx/features/discounts/models.py index f7a93b711b..bcb394e720 100644 --- a/openedx/features/discounts/models.py +++ b/openedx/features/discounts/models.py @@ -6,13 +6,12 @@ DiscountRestrictionConfig Models from django.db import models -from django.utils.encoding import python_2_unicode_compatible + from django.utils.translation import ugettext_lazy as _ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurationModel -@python_2_unicode_compatible class DiscountRestrictionConfig(StackedConfigurationModel): """ A ConfigurationModel used to manage restrictons for lms-controlled discounts @@ -41,7 +40,6 @@ class DiscountRestrictionConfig(StackedConfigurationModel): ) -@python_2_unicode_compatible class DiscountPercentageConfig(StackedConfigurationModel): """ A ConfigurationModel to configure the discount percentage for the first purchase discount