From e81a09e73ae8e2f9a7546c10a476e8f0fb1d134f Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 15 Jul 2021 00:22:51 +0500 Subject: [PATCH 1/5] Django3 has removed python_2_unicode_compatible. Execute the codemodes on this file and removed all usage. --- common/djangoapps/student/models.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index c529df7c1d..7d23d033df 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -38,7 +38,7 @@ from django.db.models import Count, Index, Q from django.db.models.signals import post_save, pre_save from django.db.utils import ProgrammingError from django.dispatch import receiver -from django.utils.encoding import python_2_unicode_compatible + from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_noop @@ -972,9 +972,6 @@ class PendingSecondaryEmailChange(DeletableByUserValue, models.Model): EVENT_NAME_ENROLLMENT_ACTIVATED = 'edx.course.enrollment.activated' EVENT_NAME_ENROLLMENT_DEACTIVATED = 'edx.course.enrollment.deactivated' EVENT_NAME_ENROLLMENT_MODE_CHANGED = 'edx.course.enrollment.mode_changed' - - -@python_2_unicode_compatible class LoginFailures(models.Model): """ This model will keep track of failed login attempts. @@ -1201,9 +1198,6 @@ class CourseEnrollmentManager(models.Manager): # CourseEnrollment for a user in a course. This type # is used to cache the state in the request cache. CourseEnrollmentState = namedtuple('CourseEnrollmentState', 'mode, is_active') - - -@python_2_unicode_compatible class CourseEnrollment(models.Model): """ Represents a Student's Enrollment record for a single Course. You should @@ -2252,7 +2246,6 @@ class CourseEnrollment(models.Model): ) -@python_2_unicode_compatible class FBEEnrollmentExclusion(models.Model): """ Disable FBE for enrollments in this table. @@ -2369,7 +2362,6 @@ class ManualEnrollmentAudit(models.Model): return True -@python_2_unicode_compatible class CourseEnrollmentAllowed(DeletableByUserValue, models.Model): """ Table of users (specified by email address strings) who are allowed to enroll in a specified course. @@ -2430,7 +2422,6 @@ class CourseEnrollmentAllowed(DeletableByUserValue, models.Model): @total_ordering -@python_2_unicode_compatible class CourseAccessRole(models.Model): """ Maps users to org, courses, and roles. Used by student.roles.CourseRole and OrgRole. @@ -2792,7 +2783,6 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel): return {'organizationName': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)} -@python_2_unicode_compatible class EntranceExamConfiguration(models.Model): """ Represents a Student's entrance exam specific data for a single Course @@ -2900,7 +2890,6 @@ class SocialLink(models.Model): social_link = models.CharField(max_length=100, blank=True) -@python_2_unicode_compatible class CourseEnrollmentAttribute(models.Model): """ Provide additional information about the user's enrollment. @@ -3008,7 +2997,6 @@ class EnrollmentRefundConfiguration(ConfigurationModel): self.refund_window_microseconds = int(refund_window.total_seconds() * 1000000) -@python_2_unicode_compatible class RegistrationCookieConfiguration(ConfigurationModel): """ Configuration for registration cookies. @@ -3057,7 +3045,6 @@ class BulkChangeEnrollmentConfiguration(ConfigurationModel): ) -@python_2_unicode_compatible class UserAttribute(TimeStampedModel): """ Record additional metadata about a user, stored as key/value pairs of text. From 0433af537f90c412dea05737c56a16f615e87038 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 15 Jul 2021 00:26:09 +0500 Subject: [PATCH 2/5] Django3 has removed python_2_unicode_compatible. Execute the codemodes on this file and removed all usage. --- lms/djangoapps/bulk_email/models.py | 10 +--------- openedx/core/djangoapps/user_api/models.py | 5 +---- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/lms/djangoapps/bulk_email/models.py b/lms/djangoapps/bulk_email/models.py index df504be4ec..42b118469d 100644 --- a/lms/djangoapps/bulk_email/models.py +++ b/lms/djangoapps/bulk_email/models.py @@ -9,7 +9,7 @@ import markupsafe from config_models.models import ConfigurationModel from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db import models -from django.utils.encoding import python_2_unicode_compatible + from opaque_keys.edx.django.models import CourseKeyField from common.djangoapps.course_modes.models import CourseMode @@ -56,9 +56,6 @@ EMAIL_TARGET_CHOICES = list(zip( ['Myself', 'Staff and instructors', 'All students', 'Specific cohort', 'Specific course mode'] )) EMAIL_TARGETS = {target[0] for target in EMAIL_TARGET_CHOICES} - - -@python_2_unicode_compatible class Target(models.Model): """ A way to refer to a particular group (within a course) as a "Send to:" target. @@ -142,7 +139,6 @@ class Target(models.Model): raise ValueError(f"Unrecognized target type {self.target_type}") -@python_2_unicode_compatible class CohortTarget(Target): """ Subclass of Target, specifically referring to a cohort. @@ -188,7 +184,6 @@ class CohortTarget(Target): return cohort -@python_2_unicode_compatible class CourseModeTarget(Target): """ Subclass of Target, specifically for course modes. @@ -236,7 +231,6 @@ class CourseModeTarget(Target): ) -@python_2_unicode_compatible class CourseEmail(Email): """ Stores information for an email to a course. @@ -431,7 +425,6 @@ class CourseEmailTemplate(models.Model): return CourseEmailTemplate._render(self.html_template, htmltext, context) -@python_2_unicode_compatible class CourseAuthorization(models.Model): """ Enable the course email feature on a course-by-course basis. @@ -465,7 +458,6 @@ class CourseAuthorization(models.Model): return f"Course '{str(self.course_id)}': Instructor Email {not_en}Enabled" -@python_2_unicode_compatible class BulkEmailFlag(ConfigurationModel): """ Enables site-wide configuration for the bulk_email feature. diff --git a/openedx/core/djangoapps/user_api/models.py b/openedx/core/djangoapps/user_api/models.py index 95f7d9da4a..605f22c6b1 100644 --- a/openedx/core/djangoapps/user_api/models.py +++ b/openedx/core/djangoapps/user_api/models.py @@ -8,7 +8,7 @@ from django.core.validators import RegexValidator from django.db import models from django.db.models.signals import post_delete, post_save, pre_save from django.dispatch import receiver -from django.utils.encoding import python_2_unicode_compatible + from model_utils.models import TimeStampedModel from opaque_keys.edx.django.models import CourseKeyField @@ -179,7 +179,6 @@ class UserOrgTag(TimeStampedModel, DeletableByUserValue): unique_together = ("user", "org", "key") -@python_2_unicode_compatible class RetirementState(models.Model): """ Stores the list and ordering of the steps of retirement, this should almost never change @@ -211,7 +210,6 @@ class RetirementState(models.Model): return cls.objects.all().values_list('state_name', flat=True) -@python_2_unicode_compatible class UserRetirementPartnerReportingStatus(TimeStampedModel): """ When a user has been retired from LMS it will still need to be reported out to @@ -241,7 +239,6 @@ class UserRetirementPartnerReportingStatus(TimeStampedModel): ) -@python_2_unicode_compatible class UserRetirementRequest(TimeStampedModel): """ Records and perists every user retirement request. From 6dc6777354a7d166b73a93fd9ef252b0200b43d9 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 15 Jul 2021 00:28:09 +0500 Subject: [PATCH 3/5] Django3 has removed python_2_unicode_compatible. Execute the codemodes on this file and removed all usage. --- lms/djangoapps/badges/models.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lms/djangoapps/badges/models.py b/lms/djangoapps/badges/models.py index 0d0bdc6f27..c0c94d00d0 100644 --- a/lms/djangoapps/badges/models.py +++ b/lms/djangoapps/badges/models.py @@ -10,7 +10,7 @@ from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.db import models -from django.utils.encoding import python_2_unicode_compatible # lint-amnesty, pylint: disable=no-name-in-module + # lint-amnesty, pylint: disable=no-name-in-module from django.utils.translation import ugettext_lazy as _ from jsonfield import JSONField from lazy import lazy # lint-amnesty, pylint: disable=no-name-in-module @@ -48,7 +48,6 @@ class CourseBadgesDisabledError(Exception): """ -@python_2_unicode_compatible class BadgeClass(models.Model): """ Specifies a badge class to be registered with a backend. @@ -146,7 +145,6 @@ class BadgeClass(models.Model): verbose_name_plural = "Badge Classes" -@python_2_unicode_compatible class BadgeAssertion(TimeStampedModel): """ Tracks badges on our side of the badge baking transaction @@ -182,9 +180,6 @@ class BadgeAssertion(TimeStampedModel): # Abstract model doesn't index this, so we have to. BadgeAssertion._meta.get_field('created').db_index = True - - -@python_2_unicode_compatible class CourseCompleteImageConfiguration(models.Model): """ Contains the icon configuration for badges for a specific course mode. @@ -240,7 +235,6 @@ class CourseCompleteImageConfiguration(models.Model): app_label = "badges" -@python_2_unicode_compatible class CourseEventBadgesConfiguration(ConfigurationModel): """ Determines the settings for meta course awards-- such as completing a certain From fe8a0c6f00c833ed76334a8ea59769dfcb9df8e5 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 15 Jul 2021 12:09:50 +0500 Subject: [PATCH 4/5] Django3 has removed python_2_unicode_compatible. Execute the codemodes on this file and removed all usage. --- common/djangoapps/student/models.py | 4 ++++ lms/djangoapps/badges/models.py | 2 ++ lms/djangoapps/bulk_email/models.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 7d23d033df..2a3a678dd7 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -972,6 +972,8 @@ class PendingSecondaryEmailChange(DeletableByUserValue, models.Model): EVENT_NAME_ENROLLMENT_ACTIVATED = 'edx.course.enrollment.activated' EVENT_NAME_ENROLLMENT_DEACTIVATED = 'edx.course.enrollment.deactivated' EVENT_NAME_ENROLLMENT_MODE_CHANGED = 'edx.course.enrollment.mode_changed' + + class LoginFailures(models.Model): """ This model will keep track of failed login attempts. @@ -1198,6 +1200,8 @@ class CourseEnrollmentManager(models.Manager): # CourseEnrollment for a user in a course. This type # is used to cache the state in the request cache. CourseEnrollmentState = namedtuple('CourseEnrollmentState', 'mode, is_active') + + class CourseEnrollment(models.Model): """ Represents a Student's Enrollment record for a single Course. You should diff --git a/lms/djangoapps/badges/models.py b/lms/djangoapps/badges/models.py index c0c94d00d0..3a4c700f5b 100644 --- a/lms/djangoapps/badges/models.py +++ b/lms/djangoapps/badges/models.py @@ -180,6 +180,8 @@ class BadgeAssertion(TimeStampedModel): # Abstract model doesn't index this, so we have to. BadgeAssertion._meta.get_field('created').db_index = True + + class CourseCompleteImageConfiguration(models.Model): """ Contains the icon configuration for badges for a specific course mode. diff --git a/lms/djangoapps/bulk_email/models.py b/lms/djangoapps/bulk_email/models.py index 42b118469d..283417252d 100644 --- a/lms/djangoapps/bulk_email/models.py +++ b/lms/djangoapps/bulk_email/models.py @@ -56,6 +56,8 @@ EMAIL_TARGET_CHOICES = list(zip( ['Myself', 'Staff and instructors', 'All students', 'Specific cohort', 'Specific course mode'] )) EMAIL_TARGETS = {target[0] for target in EMAIL_TARGET_CHOICES} + + class Target(models.Model): """ A way to refer to a particular group (within a course) as a "Send to:" target. From 65686892876a3c4b53b44f2fd370f0519e09b498 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Thu, 15 Jul 2021 13:26:17 +0500 Subject: [PATCH 5/5] Django3 has removed python_2_unicode_compatible. Execute the codemodes on this file and removed all usage. --- lms/djangoapps/badges/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lms/djangoapps/badges/models.py b/lms/djangoapps/badges/models.py index 3a4c700f5b..a6f4978c26 100644 --- a/lms/djangoapps/badges/models.py +++ b/lms/djangoapps/badges/models.py @@ -10,7 +10,6 @@ from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.db import models - # lint-amnesty, pylint: disable=no-name-in-module from django.utils.translation import ugettext_lazy as _ from jsonfield import JSONField from lazy import lazy # lint-amnesty, pylint: disable=no-name-in-module