BOM-933: Fix type mismatches in various migrations 6 (#22170)

* Fix type mismatches in coursewaqre

* Fix type mismatch in credit migrations

* Fix type mismatch in status migrations

* Fix type mismatch in user_api migrations

* Review Fixes
This commit is contained in:
Manjinder Singh
2019-10-29 10:36:10 -04:00
committed by GitHub
parent f533134db1
commit 6f1be3ed2c
8 changed files with 42 additions and 42 deletions

View File

@@ -14,6 +14,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='globalstatusmessage',
name='message',
field=models.TextField(help_text=b'<p>The contents of this field will be displayed as a warning banner on all views.</p><p>To override the banner message for a specific course, refer to the Course Message configuration. Course Messages will only work if the global status message is enabled, so if you only want to add a banner to specific courses without adding a global status message, you should add a global status message with <strong>empty</strong> message text.</p><p>Finally, disable the global status message by adding another empty message with "enabled" unchecked.</p>', null=True, blank=True),
field=models.TextField(help_text=u'<p>The contents of this field will be displayed as a warning banner on all views.</p><p>To override the banner message for a specific course, refer to the Course Message configuration. Course Messages will only work if the global status message is enabled, so if you only want to add a banner to specific courses without adding a global status message, you should add a global status message with <strong>empty</strong> message text.</p><p>Finally, disable the global status message by adding another empty message with "enabled" unchecked.</p>', null=True, blank=True),
),
]

View File

@@ -26,13 +26,13 @@ class GlobalStatusMessage(ConfigurationModel):
message = models.TextField(
blank=True,
null=True,
help_text='<p>The contents of this field will be displayed as a warning banner on all views.</p>'
'<p>To override the banner message for a specific course, refer to the Course Message configuration. '
'Course Messages will only work if the global status message is enabled, so if you only want to add '
'a banner to specific courses without adding a global status message, you should add a global status '
'message with <strong>empty</strong> message text.</p>'
'<p>Finally, disable the global status message by adding another empty message with "enabled" '
'unchecked.</p>')
help_text=u'<p>The contents of this field will be displayed as a warning banner on all views.</p>'
u'<p>To override the banner message for a specific course, refer to the Course Message configuration. '
u'Course Messages will only work if the global status message is enabled, so if you only want to add '
u'a banner to specific courses without adding a global status message, you should add a global status '
u'message with <strong>empty</strong> message text.</p>'
u'<p>Finally, disable the global status message by adding another empty message with "enabled" '
u'unchecked.</p>')
def full_message(self, course_key):
""" Returns the full status message, including any course-specific status messages. """

View File

@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='studentmodule',
name='done',
field=models.CharField(choices=[(b'na', b'NOT_APPLICABLE'), (b'f', b'FINISHED'), (b'i', b'INCOMPLETE')], default=b'na', max_length=8),
field=models.CharField(choices=[(u'na', u'NOT_APPLICABLE'), (u'f', u'FINISHED'), (u'i', u'INCOMPLETE')], default=u'na', max_length=8),
),
]

View File

@@ -112,9 +112,9 @@ class StudentModule(models.Model):
grade = models.FloatField(null=True, blank=True, db_index=True)
max_grade = models.FloatField(null=True, blank=True)
DONE_TYPES = (
('na', 'NOT_APPLICABLE'),
('f', 'FINISHED'),
('i', 'INCOMPLETE'),
(u'na', u'NOT_APPLICABLE'),
(u'f', u'FINISHED'),
(u'i', u'INCOMPLETE'),
)
done = models.CharField(max_length=8, choices=DONE_TYPES, default='na')

View File

@@ -48,17 +48,17 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('provider_id', models.CharField(help_text='Unique identifier for this credit provider. Only alphanumeric characters and hyphens (-) are allowed. The identifier is case-sensitive.', unique=True, max_length=255, validators=[django.core.validators.RegexValidator(regex=b'[a-z,A-Z,0-9,\\-]+', message=b'Only alphanumeric characters and hyphens (-) are allowed', code=b'invalid_provider_id')])),
('provider_id', models.CharField(help_text='Unique identifier for this credit provider. Only alphanumeric characters and hyphens (-) are allowed. The identifier is case-sensitive.', unique=True, max_length=255, validators=[django.core.validators.RegexValidator(regex=u'[a-z,A-Z,0-9,\\-]+', message=u'Only alphanumeric characters and hyphens (-) are allowed', code=u'invalid_provider_id')])),
('active', models.BooleanField(default=True, help_text='Whether the credit provider is currently enabled.')),
('display_name', models.CharField(help_text='Name of the credit provider displayed to users', max_length=255)),
('enable_integration', models.BooleanField(default=False, help_text='When true, automatically notify the credit provider when a user requests credit. In order for this to work, a shared secret key MUST be configured for the credit provider in secure auth settings.')),
('provider_url', models.URLField(default=b'', help_text='URL of the credit provider. If automatic integration is enabled, this will the the end-point that we POST to to notify the provider of a credit request. Otherwise, the user will be shown a link to this URL, so the user can request credit from the provider directly.')),
('provider_status_url', models.URLField(default=b'', help_text='URL from the credit provider where the user can check the status of his or her request for credit. This is displayed to students *after* they have requested credit.')),
('provider_description', models.TextField(default=b'', help_text='Description for the credit provider displayed to users.')),
('provider_url', models.URLField(default=u'', help_text='URL of the credit provider. If automatic integration is enabled, this will the the end-point that we POST to to notify the provider of a credit request. Otherwise, the user will be shown a link to this URL, so the user can request credit from the provider directly.')),
('provider_status_url', models.URLField(default=u'', help_text='URL from the credit provider where the user can check the status of his or her request for credit. This is displayed to students *after* they have requested credit.')),
('provider_description', models.TextField(default=u'', help_text='Description for the credit provider displayed to users.')),
('fulfillment_instructions', models.TextField(help_text='Plain text or html content for displaying further steps on receipt page *after* paying for the credit to get credit for a credit course against a credit provider.', null=True, blank=True)),
('eligibility_email_message', models.TextField(default=b'', help_text='Plain text or html content for displaying custom message inside credit eligibility email content which is sent when user has met all credit eligibility requirements.')),
('receipt_email_message', models.TextField(default=b'', help_text='Plain text or html content for displaying custom message inside credit receipt email content which is sent *after* paying to get credit for a credit course.')),
('thumbnail_url', models.URLField(default=b'', help_text='Thumbnail image url of the credit provider.', max_length=255)),
('eligibility_email_message', models.TextField(default=u'', help_text='Plain text or html content for displaying custom message inside credit eligibility email content which is sent when user has met all credit eligibility requirements.')),
('receipt_email_message', models.TextField(default=u'', help_text='Plain text or html content for displaying custom message inside credit receipt email content which is sent *after* paying to get credit for a credit course.')),
('thumbnail_url', models.URLField(default=u'', help_text='Thumbnail image url of the credit provider.', max_length=255)),
],
options={
'abstract': False,
@@ -73,7 +73,7 @@ class Migration(migrations.Migration):
('uuid', models.CharField(unique=True, max_length=32, db_index=True)),
('username', models.CharField(max_length=255, db_index=True)),
('parameters', jsonfield.fields.JSONField()),
('status', models.CharField(default=b'pending', max_length=255, choices=[(b'pending', b'Pending'), (b'approved', b'Approved'), (b'rejected', b'Rejected')])),
('status', models.CharField(default=u'pending', max_length=255, choices=[(u'pending', u'Pending'), (u'approved', u'Approved'), (u'rejected', u'Rejected')])),
('course', models.ForeignKey(related_name='credit_requests', to='credit.CreditCourse', on_delete=models.CASCADE)),
('provider', models.ForeignKey(related_name='credit_requests', to='credit.CreditProvider', on_delete=models.CASCADE)),
],
@@ -89,7 +89,7 @@ class Migration(migrations.Migration):
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('namespace', models.CharField(max_length=255)),
('name', models.CharField(max_length=255)),
('display_name', models.CharField(default=b'', max_length=255)),
('display_name', models.CharField(default=u'', max_length=255)),
('order', models.PositiveIntegerField(default=0)),
('criteria', jsonfield.fields.JSONField()),
('active', models.BooleanField(default=True)),
@@ -106,7 +106,7 @@ class Migration(migrations.Migration):
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('username', models.CharField(max_length=255, db_index=True)),
('status', models.CharField(max_length=32, choices=[(b'satisfied', b'satisfied'), (b'failed', b'failed'), (b'declined', b'declined')])),
('status', models.CharField(max_length=32, choices=[(u'satisfied', u'satisfied'), (u'failed', u'failed'), (u'declined', u'declined')])),
('reason', jsonfield.fields.JSONField(default={})),
('requirement', models.ForeignKey(related_name='statuses', to='credit.CreditRequirement', on_delete=models.CASCADE)),
],
@@ -120,7 +120,7 @@ class Migration(migrations.Migration):
('uuid', models.CharField(max_length=32, db_index=True)),
('username', models.CharField(max_length=255, db_index=True)),
('parameters', jsonfield.fields.JSONField()),
('status', models.CharField(default=b'pending', max_length=255, choices=[(b'pending', b'Pending'), (b'approved', b'Approved'), (b'rejected', b'Rejected')])),
('status', models.CharField(default=u'pending', max_length=255, choices=[(u'pending', u'Pending'), (u'approved', u'Approved'), (u'rejected', u'Rejected')])),
('history_id', models.AutoField(serialize=False, primary_key=True)),
('history_date', models.DateTimeField()),
('history_type', models.CharField(max_length=1, choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')])),
@@ -141,7 +141,7 @@ class Migration(migrations.Migration):
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, verbose_name='created', editable=False)),
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, verbose_name='modified', editable=False)),
('username', models.CharField(max_length=255, db_index=True)),
('status', models.CharField(max_length=32, choices=[(b'satisfied', b'satisfied'), (b'failed', b'failed'), (b'declined', b'declined')])),
('status', models.CharField(max_length=32, choices=[(u'satisfied', u'satisfied'), (u'failed', u'failed'), (u'declined', u'declined')])),
('reason', jsonfield.fields.JSONField(default={})),
('history_id', models.AutoField(serialize=False, primary_key=True)),
('history_date', models.DateTimeField()),

View File

@@ -30,7 +30,7 @@ from opaque_keys.edx.django.models import CourseKeyField
from openedx.core.lib.cache_utils import request_cached
CREDIT_PROVIDER_ID_REGEX = r"[a-z,A-Z,0-9,\-]+"
CREDIT_PROVIDER_ID_REGEX = u"[a-z,A-Z,0-9,\\-]+"
log = logging.getLogger(__name__)
@@ -52,8 +52,8 @@ class CreditProvider(TimeStampedModel):
validators=[
RegexValidator(
regex=CREDIT_PROVIDER_ID_REGEX,
message="Only alphanumeric characters and hyphens (-) are allowed",
code="invalid_provider_id",
message=u"Only alphanumeric characters and hyphens (-) are allowed",
code=u"invalid_provider_id",
)
],
help_text=ugettext_lazy(
@@ -84,7 +84,7 @@ class CreditProvider(TimeStampedModel):
)
provider_url = models.URLField(
default="",
default=u"",
help_text=ugettext_lazy(
"URL of the credit provider. If automatic integration is "
"enabled, this will the the end-point that we POST to "
@@ -95,7 +95,7 @@ class CreditProvider(TimeStampedModel):
)
provider_status_url = models.URLField(
default="",
default=u"",
help_text=ugettext_lazy(
"URL from the credit provider where the user can check the status "
"of his or her request for credit. This is displayed to students "
@@ -104,7 +104,7 @@ class CreditProvider(TimeStampedModel):
)
provider_description = models.TextField(
default="",
default=u"",
help_text=ugettext_lazy(
"Description for the credit provider displayed to users."
)
@@ -121,7 +121,7 @@ class CreditProvider(TimeStampedModel):
)
eligibility_email_message = models.TextField(
default="",
default=u"",
help_text=ugettext_lazy(
"Plain text or html content for displaying custom message inside "
"credit eligibility email content which is sent when user has met "
@@ -130,7 +130,7 @@ class CreditProvider(TimeStampedModel):
)
receipt_email_message = models.TextField(
default="",
default=u"",
help_text=ugettext_lazy(
"Plain text or html content for displaying custom message inside "
"credit receipt email content which is sent *after* paying to get "
@@ -139,7 +139,7 @@ class CreditProvider(TimeStampedModel):
)
thumbnail_url = models.URLField(
default="",
default=u"",
max_length=255,
help_text=ugettext_lazy(
"Thumbnail image url of the credit provider."
@@ -300,7 +300,7 @@ class CreditRequirement(TimeStampedModel):
course = models.ForeignKey(CreditCourse, related_name="credit_requirements", on_delete=models.CASCADE)
namespace = models.CharField(max_length=255)
name = models.CharField(max_length=255)
display_name = models.CharField(max_length=255, default="")
display_name = models.CharField(max_length=255, default=u"")
order = models.PositiveIntegerField(default=0)
criteria = JSONField()
active = models.BooleanField(default=True)
@@ -677,14 +677,14 @@ class CreditRequest(TimeStampedModel):
provider = models.ForeignKey(CreditProvider, related_name="credit_requests", on_delete=models.CASCADE)
parameters = JSONField()
REQUEST_STATUS_PENDING = "pending"
REQUEST_STATUS_APPROVED = "approved"
REQUEST_STATUS_REJECTED = "rejected"
REQUEST_STATUS_PENDING = u"pending"
REQUEST_STATUS_APPROVED = u"approved"
REQUEST_STATUS_REJECTED = u"rejected"
REQUEST_STATUS_CHOICES = (
(REQUEST_STATUS_PENDING, "Pending"),
(REQUEST_STATUS_APPROVED, "Approved"),
(REQUEST_STATUS_REJECTED, "Rejected"),
(REQUEST_STATUS_PENDING, u"Pending"),
(REQUEST_STATUS_APPROVED, u"Approved"),
(REQUEST_STATUS_REJECTED, u"Rejected"),
)
status = models.CharField(
max_length=255,

View File

@@ -42,7 +42,7 @@ class Migration(migrations.Migration):
name='UserPreference',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('key', models.CharField(db_index=True, max_length=255, validators=[django.core.validators.RegexValidator(b'[-_a-zA-Z0-9]+')])),
('key', models.CharField(db_index=True, max_length=255, validators=[django.core.validators.RegexValidator(u'[-_a-zA-Z0-9]+')])),
('value', models.TextField()),
('user', models.ForeignKey(related_name='preferences', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
],

View File

@@ -45,7 +45,7 @@ class UserPreference(models.Model):
.. no_pii: Stores arbitrary key/value pairs, currently none are PII. If that changes, update this annotation.
"""
KEY_REGEX = r"[-_a-zA-Z0-9]+"
KEY_REGEX = u"[-_a-zA-Z0-9]+"
user = models.ForeignKey(User, db_index=True, related_name="preferences", on_delete=models.CASCADE)
key = models.CharField(max_length=255, db_index=True, validators=[RegexValidator(KEY_REGEX)])
value = models.TextField()