From 897bd25b013d1a2da30ff8c6964026b69ae6b172 Mon Sep 17 00:00:00 2001 From: Ayub khan Date: Tue, 22 Oct 2019 16:27:26 +0500 Subject: [PATCH] BOM-949 student: Explicitly Set fields to unicode to avoid migration --- common/djangoapps/course_modes/models.py | 14 ++--- .../student/migrations/0001_initial.py | 22 +++---- .../migrations/0002_auto_20151208_1034.py | 4 +- .../migrations/0008_auto_20161117_1209.py | 2 +- .../migrations/0019_auto_20181221_0540.py | 2 +- .../0021_historicalcourseenrollment.py | 2 +- .../0023_bulkunenrollconfiguration.py | 2 +- common/djangoapps/student/models.py | 60 +++++++++---------- lms/envs/common.py | 6 +- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/common/djangoapps/course_modes/models.py b/common/djangoapps/course_modes/models.py index 04588a3428..7d4d90fce5 100644 --- a/common/djangoapps/course_modes/models.py +++ b/common/djangoapps/course_modes/models.py @@ -145,13 +145,13 @@ class CourseMode(models.Model): history = HistoricalRecords() - HONOR = 'honor' - PROFESSIONAL = 'professional' - VERIFIED = 'verified' - AUDIT = 'audit' - NO_ID_PROFESSIONAL_MODE = 'no-id-professional' - CREDIT_MODE = 'credit' - MASTERS = 'masters' + HONOR = u'honor' + PROFESSIONAL = u'professional' + VERIFIED = u'verified' + AUDIT = u'audit' + NO_ID_PROFESSIONAL_MODE = u'no-id-professional' + CREDIT_MODE = u'credit' + MASTERS = u'masters' DEFAULT_MODE = Mode( settings.COURSE_MODE_DEFAULTS['slug'], diff --git a/common/djangoapps/student/migrations/0001_initial.py b/common/djangoapps/student/migrations/0001_initial.py index db1e6f0f33..f7aac2b787 100644 --- a/common/djangoapps/student/migrations/0001_initial.py +++ b/common/djangoapps/student/migrations/0001_initial.py @@ -75,7 +75,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('change_date', models.DateTimeField(auto_now_add=True, verbose_name='Change date')), ('enabled', models.BooleanField(default=False, verbose_name='Enabled')), - ('recent_enrollment_time_delta', models.PositiveIntegerField(default=0, help_text=b"The number of seconds in which a new enrollment is considered 'recent'. Used to display notifications.")), + ('recent_enrollment_time_delta', models.PositiveIntegerField(default=0, help_text=u"The number of seconds in which a new enrollment is considered 'recent'. Used to display notifications.")), ('changed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Changed by')), ], options={ @@ -141,9 +141,9 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('change_date', models.DateTimeField(auto_now_add=True, verbose_name='Change date')), ('enabled', models.BooleanField(default=False, verbose_name='Enabled')), - ('company_identifier', models.TextField(help_text='The company identifier for the LinkedIn Add-to-Profile button e.g 0_0dPSPyS070e0HsE9HNz_13_d11_')), - ('dashboard_tracking_code', models.TextField(default=b'', blank=True)), - ('trk_partner_name', models.CharField(default=b'', help_text="Short identifier for the LinkedIn partner used in the tracking code. (Example: 'edx') If no value is provided, tracking codes will not be sent to LinkedIn.", max_length=10, blank=True)), + ('company_identifier', models.TextField(help_text=u'The company identifier for the LinkedIn Add-to-Profile button e.g 0_0dPSPyS070e0HsE9HNz_13_d11_')), + ('dashboard_tracking_code', models.TextField(default=u'', blank=True)), + ('trk_partner_name', models.CharField(default=u'', help_text=u"Short identifier for the LinkedIn partner used in the tracking code. (Example: 'edx') If no value is provided, tracking codes will not be sent to LinkedIn.", max_length=10, blank=True)), ('changed_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, editable=False, to=settings.AUTH_USER_MODEL, null=True, verbose_name='Changed by')), ], options={ @@ -166,7 +166,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('enrolled_email', models.CharField(max_length=255, db_index=True)), ('time_stamp', models.DateTimeField(auto_now_add=True, null=True)), - ('state_transition', models.CharField(max_length=255, choices=[(b'from unenrolled to allowed to enroll', b'from unenrolled to allowed to enroll'), (b'from allowed to enroll to enrolled', b'from allowed to enroll to enrolled'), (b'from enrolled to enrolled', b'from enrolled to enrolled'), (b'from enrolled to unenrolled', b'from enrolled to unenrolled'), (b'from unenrolled to enrolled', b'from unenrolled to enrolled'), (b'from allowed to enroll to enrolled', b'from allowed to enroll to enrolled'), (b'from unenrolled to unenrolled', b'from unenrolled to unenrolled'), (b'N/A', b'N/A')])), + ('state_transition', models.CharField(max_length=255, choices=[(u'from unenrolled to allowed to enroll', u'from unenrolled to allowed to enroll'), (u'from allowed to enroll to enrolled', u'from allowed to enroll to enrolled'), (u'from enrolled to enrolled', u'from enrolled to enrolled'), (u'from enrolled to unenrolled', u'from enrolled to unenrolled'), (u'from unenrolled to enrolled', u'from unenrolled to enrolled'), (u'from allowed to enroll to enrolled', u'from allowed to enroll to enrolled'), (u'from unenrolled to unenrolled', u'from unenrolled to unenrolled'), (u'N/A', u'N/A')])), ('reason', models.TextField(null=True)), ('enrolled_by', models.ForeignKey(to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)), ('enrollment', models.ForeignKey(to='student.CourseEnrollment', null=True, on_delete=models.CASCADE)), @@ -186,7 +186,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('new_email', models.CharField(db_index=True, max_length=255, blank=True)), - ('activation_key', models.CharField(unique=True, max_length=32, verbose_name=b'activation key', db_index=True)), + ('activation_key', models.CharField(unique=True, max_length=32, verbose_name=u'activation key', db_index=True)), ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], ), @@ -203,7 +203,7 @@ class Migration(migrations.Migration): name='Registration', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('activation_key', models.CharField(unique=True, max_length=32, verbose_name=b'activation key', db_index=True)), + ('activation_key', models.CharField(unique=True, max_length=32, verbose_name=u'activation key', db_index=True)), ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ @@ -216,12 +216,12 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(db_index=True, max_length=255, blank=True)), ('meta', models.TextField(blank=True)), - ('courseware', models.CharField(default=b'course.xml', max_length=255, blank=True)), + ('courseware', models.CharField(default=u'course.xml', max_length=255, blank=True)), ('language', models.CharField(db_index=True, max_length=255, blank=True)), ('location', models.CharField(db_index=True, max_length=255, blank=True)), ('year_of_birth', models.IntegerField(db_index=True, null=True, blank=True)), - ('gender', models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(b'm', b'Male'), (b'f', b'Female'), (b'o', b'Other/Prefer Not to Say')])), - ('level_of_education', models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(b'p', b'Doctorate'), (b'm', b"Master's or professional degree"), (b'b', b"Bachelor's degree"), (b'a', b'Associate degree'), (b'hs', b'Secondary/high school'), (b'jhs', b'Junior secondary/junior high/middle school'), (b'el', b'Elementary/primary school'), (b'none', b'No Formal Education'), (b'other', b'Other Education')])), + ('gender', models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(u'm', u'Male'), (u'f', u'Female'), (u'o', u'Other/Prefer Not to Say')])), + ('level_of_education', models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(u'p', u'Doctorate'), (u'm', u"Master's or professional degree"), (u'b', u"Bachelor's degree"), (u'a', u'Associate degree'), (u'hs', u'Secondary/high school'), (u'jhs', u'Junior secondary/junior high/middle school'), (u'el', u'Elementary/primary school'), (u'none', u'No Formal Education'), (u'other', u'Other Education')])), ('mailing_address', models.TextField(null=True, blank=True)), ('city', models.TextField(null=True, blank=True)), ('country', django_countries.fields.CountryField(blank=True, max_length=2, null=True)), @@ -247,7 +247,7 @@ class Migration(migrations.Migration): name='UserStanding', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), - ('account_status', models.CharField(blank=True, max_length=31, choices=[(b'disabled', 'Account Disabled'), (b'enabled', 'Account Enabled')])), + ('account_status', models.CharField(blank=True, max_length=31, choices=[(u'disabled', u'Account Disabled'), (u'enabled', u'Account Enabled')])), ('standing_last_changed_at', models.DateTimeField(auto_now=True)), ('changed_by', models.ForeignKey(to=settings.AUTH_USER_MODEL, blank=True, on_delete=models.CASCADE)), ('user', models.OneToOneField(related_name='standing', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), diff --git a/common/djangoapps/student/migrations/0002_auto_20151208_1034.py b/common/djangoapps/student/migrations/0002_auto_20151208_1034.py index 1b6b34771f..f0d9d4c260 100644 --- a/common/djangoapps/student/migrations/0002_auto_20151208_1034.py +++ b/common/djangoapps/student/migrations/0002_auto_20151208_1034.py @@ -14,11 +14,11 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='courseenrollment', name='mode', - field=models.CharField(default=b'audit', max_length=100), + field=models.CharField(default=u'audit', max_length=100), ), migrations.AlterField( model_name='historicalcourseenrollment', name='mode', - field=models.CharField(default=b'audit', max_length=100), + field=models.CharField(default=u'audit', max_length=100), ), ] diff --git a/common/djangoapps/student/migrations/0008_auto_20161117_1209.py b/common/djangoapps/student/migrations/0008_auto_20161117_1209.py index 8e062e89c9..d84651b254 100644 --- a/common/djangoapps/student/migrations/0008_auto_20161117_1209.py +++ b/common/djangoapps/student/migrations/0008_auto_20161117_1209.py @@ -14,6 +14,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='userprofile', name='level_of_education', - field=models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(b'p', b'Doctorate'), (b'm', b"Master's or professional degree"), (b'b', b"Bachelor's degree"), (b'a', b'Associate degree'), (b'hs', b'Secondary/high school'), (b'jhs', b'Junior secondary/junior high/middle school'), (b'el', b'Elementary/primary school'), (b'none', b'No formal education'), (b'other', b'Other education')]), + field=models.CharField(blank=True, max_length=6, null=True, db_index=True, choices=[(u'p', u'Doctorate'), (u'm', u"Master's or professional degree"), (u'b', u"Bachelor's degree"), (u'a', u'Associate degree'), (u'hs', u'Secondary/high school'), (u'jhs', u'Junior secondary/junior high/middle school'), (u'el', u'Elementary/primary school'), (u'none', u'No formal education'), (u'other', u'Other education')]), ), ] diff --git a/common/djangoapps/student/migrations/0019_auto_20181221_0540.py b/common/djangoapps/student/migrations/0019_auto_20181221_0540.py index 1847c41645..e7e2b14d6c 100644 --- a/common/djangoapps/student/migrations/0019_auto_20181221_0540.py +++ b/common/djangoapps/student/migrations/0019_auto_20181221_0540.py @@ -22,7 +22,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('new_secondary_email', models.CharField(blank=True, db_index=True, max_length=255)), - ('activation_key', models.CharField(db_index=True, max_length=32, unique=True, verbose_name=b'activation key')), + ('activation_key', models.CharField(db_index=True, max_length=32, unique=True, verbose_name=u'activation key')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], bases=(openedx.core.djangolib.model_mixins.DeletableByUserValue, models.Model), diff --git a/common/djangoapps/student/migrations/0021_historicalcourseenrollment.py b/common/djangoapps/student/migrations/0021_historicalcourseenrollment.py index 0e9617fc0f..8436060d82 100644 --- a/common/djangoapps/student/migrations/0021_historicalcourseenrollment.py +++ b/common/djangoapps/student/migrations/0021_historicalcourseenrollment.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): ('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')), ('created', models.DateTimeField(blank=True, db_index=True, editable=False, null=True)), ('is_active', models.BooleanField(default=True)), - ('mode', models.CharField(default=b'audit', max_length=100)), + ('mode', models.CharField(default=u'audit', max_length=100)), ('history_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('history_date', models.DateTimeField()), ('history_change_reason', models.CharField(max_length=100, null=True)), diff --git a/common/djangoapps/student/migrations/0023_bulkunenrollconfiguration.py b/common/djangoapps/student/migrations/0023_bulkunenrollconfiguration.py index 774a70b254..2e551f5978 100644 --- a/common/djangoapps/student/migrations/0023_bulkunenrollconfiguration.py +++ b/common/djangoapps/student/migrations/0023_bulkunenrollconfiguration.py @@ -22,7 +22,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('change_date', models.DateTimeField(auto_now_add=True, verbose_name='Change date')), ('enabled', models.BooleanField(default=False, verbose_name='Enabled')), - ('csv_file', models.FileField(help_text='It expect that the data will be provided in a csv file format with first row being the header and columns will be as follows: user_id, username, email, course_id, is_verified, verification_date', upload_to=b'', validators=[django.core.validators.FileExtensionValidator(allowed_extensions=[b'csv'])])), + ('csv_file', models.FileField(help_text='It expect that the data will be provided in a csv file format with first row being the header and columns will be as follows: user_id, username, email, course_id, is_verified, verification_date', upload_to=u'', validators=[django.core.validators.FileExtensionValidator(allowed_extensions=[u'csv'])])), ('changed_by', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Changed by')), ], options={ diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index 43b350a2e4..01ad3b3c87 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -105,14 +105,14 @@ class EnrollStatusChange(object): # complete a paid course purchase paid_complete = 'paid_complete' -UNENROLLED_TO_ALLOWEDTOENROLL = 'from unenrolled to allowed to enroll' -ALLOWEDTOENROLL_TO_ENROLLED = 'from allowed to enroll to enrolled' -ENROLLED_TO_ENROLLED = 'from enrolled to enrolled' -ENROLLED_TO_UNENROLLED = 'from enrolled to unenrolled' -UNENROLLED_TO_ENROLLED = 'from unenrolled to enrolled' -ALLOWEDTOENROLL_TO_UNENROLLED = 'from allowed to enroll to enrolled' -UNENROLLED_TO_UNENROLLED = 'from unenrolled to unenrolled' -DEFAULT_TRANSITION_STATE = 'N/A' +UNENROLLED_TO_ALLOWEDTOENROLL = u'from unenrolled to allowed to enroll' +ALLOWEDTOENROLL_TO_ENROLLED = u'from allowed to enroll to enrolled' +ENROLLED_TO_ENROLLED = u'from enrolled to enrolled' +ENROLLED_TO_UNENROLLED = u'from enrolled to unenrolled' +UNENROLLED_TO_ENROLLED = u'from unenrolled to enrolled' +ALLOWEDTOENROLL_TO_UNENROLLED = u'from allowed to enroll to enrolled' +UNENROLLED_TO_UNENROLLED = u'from unenrolled to unenrolled' +DEFAULT_TRANSITION_STATE = u'N/A' SCORE_RECALCULATION_DELAY_ON_ENROLLMENT_UPDATE = 30 TRANSITION_STATES = ( @@ -390,8 +390,8 @@ class UserStanding(models.Model): .. no_pii: """ - ACCOUNT_DISABLED = "disabled" - ACCOUNT_ENABLED = "enabled" + ACCOUNT_DISABLED = u"disabled" + ACCOUNT_ENABLED = u"enabled" USER_STANDING_CHOICES = ( (ACCOUNT_DISABLED, u"Account Disabled"), (ACCOUNT_ENABLED, u"Account Enabled"), @@ -441,7 +441,7 @@ class UserProfile(models.Model): name = models.CharField(blank=True, max_length=255, db_index=True) meta = models.TextField(blank=True) # JSON dictionary for future expansion - courseware = models.CharField(blank=True, max_length=255, default='course.xml') + courseware = models.CharField(blank=True, max_length=255, default=u'course.xml') # Language is deprecated and no longer used. Old rows exist that have # user-entered free form text values (ex. "English"), some of which have @@ -459,10 +459,10 @@ class UserProfile(models.Model): VALID_YEARS = list(range(this_year, this_year - 120, -1)) year_of_birth = models.IntegerField(blank=True, null=True, db_index=True) GENDER_CHOICES = ( - ('m', ugettext_noop('Male')), - ('f', ugettext_noop('Female')), + (u'm', ugettext_noop(u'Male')), + (u'f', ugettext_noop(u'Female')), # Translators: 'Other' refers to the student's gender - ('o', ugettext_noop('Other/Prefer Not to Say')) + (u'o', ugettext_noop(u'Other/Prefer Not to Say')) ) gender = models.CharField( blank=True, null=True, max_length=6, db_index=True, choices=GENDER_CHOICES @@ -473,17 +473,17 @@ class UserProfile(models.Model): # ('p_se', 'Doctorate in science or engineering'), # ('p_oth', 'Doctorate in another field'), LEVEL_OF_EDUCATION_CHOICES = ( - ('p', ugettext_noop('Doctorate')), - ('m', ugettext_noop("Master's or professional degree")), - ('b', ugettext_noop("Bachelor's degree")), - ('a', ugettext_noop("Associate degree")), - ('hs', ugettext_noop("Secondary/high school")), - ('jhs', ugettext_noop("Junior secondary/junior high/middle school")), - ('el', ugettext_noop("Elementary/primary school")), + (u'p', ugettext_noop(u'Doctorate')), + (u'm', ugettext_noop(u"Master's or professional degree")), + (u'b', ugettext_noop(u"Bachelor's degree")), + (u'a', ugettext_noop(u"Associate degree")), + (u'hs', ugettext_noop(u"Secondary/high school")), + (u'jhs', ugettext_noop(u"Junior secondary/junior high/middle school")), + (u'el', ugettext_noop(u"Elementary/primary school")), # Translators: 'None' refers to the student's level of education - ('none', ugettext_noop("No formal education")), + (u'none', ugettext_noop(u"No formal education")), # Translators: 'Other' refers to the student's level of education - ('other', ugettext_noop("Other education")) + (u'other', ugettext_noop(u"Other education")) ) level_of_education = models.CharField( blank=True, null=True, max_length=6, db_index=True, @@ -763,7 +763,7 @@ class Registration(models.Model): db_table = "auth_registration" user = models.OneToOneField(User, on_delete=models.CASCADE) - activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) + activation_key = models.CharField((u'activation key'), max_length=32, unique=True, db_index=True) def register(self, user): # MINOR TODO: Switch to crypto-secure key @@ -800,7 +800,7 @@ class PendingEmailChange(DeletableByUserValue, models.Model): """ user = models.OneToOneField(User, unique=True, db_index=True, on_delete=models.CASCADE) new_email = models.CharField(blank=True, max_length=255, db_index=True) - activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) + activation_key = models.CharField((u'activation key'), max_length=32, unique=True, db_index=True) def request_change(self, email): """Request a change to a user's email. @@ -830,7 +830,7 @@ class PendingSecondaryEmailChange(DeletableByUserValue, models.Model): """ user = models.OneToOneField(User, unique=True, db_index=True, on_delete=models.CASCADE) new_secondary_email = models.CharField(blank=True, max_length=255, db_index=True) - activation_key = models.CharField(('activation key'), max_length=32, unique=True, db_index=True) + activation_key = models.CharField((u'activation key'), max_length=32, unique=True, db_index=True) EVENT_NAME_ENROLLMENT_ACTIVATED = 'edx.course.enrollment.activated' @@ -2429,7 +2429,7 @@ class DashboardConfiguration(ConfigurationModel): """ recent_enrollment_time_delta = models.PositiveIntegerField( default=0, - help_text="The number of seconds in which a new enrollment is considered 'recent'. " + help_text=u"The number of seconds in which a new enrollment is considered 'recent'. " "Used to display notifications." ) @@ -2469,7 +2469,7 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel): ) # Deprecated - dashboard_tracking_code = models.TextField(default="", blank=True) + dashboard_tracking_code = models.TextField(default=u"", blank=True) trk_partner_name = models.CharField( max_length=10, @@ -2819,8 +2819,8 @@ class BulkUnenrollConfiguration(ConfigurationModel): """ csv_file = models.FileField( - validators=[FileExtensionValidator(allowed_extensions=['csv'])], - help_text=_("It expect that the data will be provided in a csv file format with \ + validators=[FileExtensionValidator(allowed_extensions=[u'csv'])], + help_text=_(u"It expect that the data will be provided in a csv file format with \ first row being the header and columns will be as follows: \ user_id, username, email, course_id, is_verified, verification_date") ) diff --git a/lms/envs/common.py b/lms/envs/common.py index 5abb1273c4..d609330876 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -792,13 +792,13 @@ WIKI_ENABLED = True COURSE_MODE_DEFAULTS = { 'bulk_sku': None, - 'currency': 'usd', + 'currency': u'usd', 'description': None, 'expiration_datetime': None, 'min_price': 0, - 'name': _('Audit'), + 'name': _(u'Audit'), 'sku': None, - 'slug': 'audit', + 'slug': u'audit', 'suggested_prices': '', }