Merge pull request #21735 from edx/BOM-update_str_method
BOM Project __unicode__ to __str__
This commit is contained in:
@@ -11,6 +11,7 @@ from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from jsonfield import JSONField
|
||||
from lazy import lazy
|
||||
@@ -48,6 +49,7 @@ class CourseBadgesDisabledError(Exception):
|
||||
"""
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class BadgeClass(models.Model):
|
||||
"""
|
||||
Specifies a badge class to be registered with a backend.
|
||||
@@ -64,7 +66,7 @@ class BadgeClass(models.Model):
|
||||
mode = models.CharField(max_length=100, default='', blank=True)
|
||||
image = models.ImageField(upload_to='badge_classes', validators=[validate_badge_image])
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return HTML(u"<Badge '{slug}' for '{issuing_component}'>").format(
|
||||
slug=HTML(self.slug), issuing_component=HTML(self.issuing_component)
|
||||
)
|
||||
@@ -143,6 +145,7 @@ 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
|
||||
@@ -156,7 +159,7 @@ class BadgeAssertion(TimeStampedModel):
|
||||
image_url = models.URLField()
|
||||
assertion_url = models.URLField()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return HTML(u"<{username} Badge Assertion for {slug} for {issuing_component}").format(
|
||||
username=HTML(self.user.username),
|
||||
slug=HTML(self.badge_class.slug),
|
||||
@@ -180,6 +183,7 @@ class BadgeAssertion(TimeStampedModel):
|
||||
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.
|
||||
@@ -207,7 +211,7 @@ class CourseCompleteImageConfiguration(models.Model):
|
||||
default=False,
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return HTML(u"<CourseCompleteImageConfiguration for '{mode}'{default}>").format(
|
||||
mode=HTML(self.mode),
|
||||
default=HTML(u" (default)") if self.default else HTML(u'')
|
||||
@@ -235,6 +239,7 @@ 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
|
||||
@@ -268,7 +273,7 @@ class CourseEventBadgesConfiguration(ConfigurationModel):
|
||||
)
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return HTML(u"<CourseEventBadgesConfiguration ({})>").format(
|
||||
Text(u"Enabled") if self.enabled else Text(u"Disabled")
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@ import six
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
from six import text_type
|
||||
from six.moves import zip
|
||||
@@ -60,6 +61,7 @@ EMAIL_TARGET_CHOICES = list(zip(
|
||||
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.
|
||||
@@ -79,7 +81,7 @@ class Target(models.Model):
|
||||
class Meta(object):
|
||||
app_label = "bulk_email"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "CourseEmail Target: {}".format(self.short_display())
|
||||
|
||||
def short_display(self):
|
||||
@@ -143,6 +145,7 @@ class Target(models.Model):
|
||||
raise ValueError(u"Unrecognized target type {}".format(self.target_type))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CohortTarget(Target):
|
||||
"""
|
||||
Subclass of Target, specifically referring to a cohort.
|
||||
@@ -158,7 +161,7 @@ class CohortTarget(Target):
|
||||
kwargs['target_type'] = SEND_TO_COHORT
|
||||
super(CohortTarget, self).__init__(*args, **kwargs)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.short_display()
|
||||
|
||||
def short_display(self):
|
||||
@@ -188,6 +191,7 @@ class CohortTarget(Target):
|
||||
return cohort
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseModeTarget(Target):
|
||||
"""
|
||||
Subclass of Target, specifically for course modes.
|
||||
@@ -203,7 +207,7 @@ class CourseModeTarget(Target):
|
||||
kwargs['target_type'] = SEND_TO_TRACK
|
||||
super(CourseModeTarget, self).__init__(*args, **kwargs)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.short_display()
|
||||
|
||||
def short_display(self):
|
||||
@@ -235,6 +239,7 @@ class CourseModeTarget(Target):
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseEmail(Email):
|
||||
"""
|
||||
Stores information for an email to a course.
|
||||
@@ -251,7 +256,7 @@ class CourseEmail(Email):
|
||||
template_name = models.CharField(null=True, max_length=255)
|
||||
from_addr = models.CharField(null=True, max_length=255)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.subject
|
||||
|
||||
@classmethod
|
||||
@@ -429,6 +434,7 @@ 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.
|
||||
@@ -455,7 +461,7 @@ class CourseAuthorization(models.Model):
|
||||
except cls.DoesNotExist:
|
||||
return False
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
not_en = "Not "
|
||||
if self.email_enabled:
|
||||
not_en = ""
|
||||
@@ -474,6 +480,7 @@ class CourseAuthorization(models.Model):
|
||||
# .. toggle_warnings: None
|
||||
# .. toggle_tickets: None
|
||||
# .. toggle_status: supported
|
||||
@python_2_unicode_compatible
|
||||
class BulkEmailFlag(ConfigurationModel):
|
||||
"""
|
||||
Enables site-wide configuration for the bulk_email feature.
|
||||
@@ -512,7 +519,7 @@ class BulkEmailFlag(ConfigurationModel):
|
||||
class Meta(object):
|
||||
app_label = "bulk_email"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
current_model = BulkEmailFlag.current()
|
||||
return u"BulkEmailFlag: enabled {}, require_course_email_auth: {}".format(
|
||||
current_model.is_enabled(),
|
||||
|
||||
@@ -288,7 +288,7 @@ class CourseAuthorizationTest(TestCase):
|
||||
# Now, course should be authorized
|
||||
self.assertTrue(is_bulk_email_feature_enabled(course_id))
|
||||
self.assertEqual(
|
||||
cauth.__unicode__(),
|
||||
str(cauth),
|
||||
"Course 'abc/123/doremi': Instructor Email Enabled"
|
||||
)
|
||||
|
||||
@@ -298,7 +298,7 @@ class CourseAuthorizationTest(TestCase):
|
||||
# Test that course is now unauthorized
|
||||
self.assertFalse(is_bulk_email_feature_enabled(course_id))
|
||||
self.assertEqual(
|
||||
cauth.__unicode__(),
|
||||
str(cauth),
|
||||
"Course 'abc/123/doremi': Instructor Email Not Enabled"
|
||||
)
|
||||
|
||||
|
||||
@@ -60,6 +60,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
|
||||
@@ -404,6 +405,7 @@ class GeneratedCertificate(models.Model):
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CertificateGenerationHistory(TimeStampedModel):
|
||||
"""
|
||||
Model for storing Certificate Generation History.
|
||||
@@ -463,11 +465,12 @@ class CertificateGenerationHistory(TimeStampedModel):
|
||||
class Meta(object):
|
||||
app_label = "certificates"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"certificates %s by %s on %s for %s" % \
|
||||
("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.
|
||||
@@ -482,7 +485,7 @@ class CertificateInvalidation(TimeStampedModel):
|
||||
class Meta(object):
|
||||
app_label = "certificates"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"Certificate %s, invalidated by %s on %s." % \
|
||||
(self.generated_certificate, self.invalidated_by, self.created)
|
||||
|
||||
@@ -1067,6 +1070,7 @@ class CertificateHtmlViewConfiguration(ConfigurationModel):
|
||||
return json_data
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CertificateTemplate(TimeStampedModel):
|
||||
"""A set of custom web certificate templates.
|
||||
|
||||
@@ -1123,7 +1127,7 @@ class CertificateTemplate(TimeStampedModel):
|
||||
u'Course language is determined by the first two letters of the language code.'
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u'%s' % (self.name, )
|
||||
|
||||
class Meta(object):
|
||||
@@ -1147,6 +1151,7 @@ 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.
|
||||
|
||||
@@ -1183,7 +1188,7 @@ class CertificateTemplateAsset(TimeStampedModel):
|
||||
|
||||
super(CertificateTemplateAsset, self).save(*args, **kwargs)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u'%s' % (self.asset.url, )
|
||||
|
||||
class Meta(object):
|
||||
|
||||
@@ -11,6 +11,7 @@ import six
|
||||
from django.conf import settings
|
||||
from django.test.client import RequestFactory
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from lxml.etree import ParserError, XMLSyntaxError
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
@@ -31,6 +32,7 @@ from xmodule.modulestore.django import modulestore
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class XQueueAddToQueueError(Exception):
|
||||
"""An error occurred when adding a certificate task to the queue. """
|
||||
|
||||
@@ -39,7 +41,7 @@ class XQueueAddToQueueError(Exception):
|
||||
self.error_msg = error_msg
|
||||
super(XQueueAddToQueueError, self).__init__(six.text_type(self))
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return (
|
||||
u"Could not add certificate to the XQueue. "
|
||||
u"The error code was '{code}' and the message was '{msg}'."
|
||||
|
||||
@@ -5,9 +5,11 @@ from __future__ import absolute_import
|
||||
|
||||
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
|
||||
@@ -52,7 +54,7 @@ class CommerceConfiguration(ConfigurationModel):
|
||||
help_text=_('Automatically approve valid refund requests, without manual processing')
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "Commerce configuration"
|
||||
|
||||
@property
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import absolute_import
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from model_utils import Choices
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
@@ -18,6 +19,7 @@ GOAL_KEY_CHOICES = Choices(
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseGoal(models.Model):
|
||||
"""
|
||||
Represents a course goal set by a user on the course home page.
|
||||
@@ -32,7 +34,7 @@ class CourseGoal(models.Model):
|
||||
course_key = CourseKeyField(max_length=255, db_index=True)
|
||||
goal_key = models.CharField(max_length=100, choices=GOAL_KEY_CHOICES, default=GOAL_KEY_CHOICES.unsure)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return 'CourseGoal: {user} set goal to {goal} for course {course}'.format(
|
||||
user=self.user.username,
|
||||
goal=self.goal_key,
|
||||
|
||||
@@ -23,6 +23,7 @@ from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from model_utils.models import TimeStampedModel
|
||||
from opaque_keys.edx.django.models import BlockTypeKeyField, CourseKeyField, LearningContextKeyField, UsageKeyField
|
||||
@@ -77,6 +78,7 @@ class ChunkingManager(models.Manager):
|
||||
return res
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class StudentModule(models.Model):
|
||||
"""
|
||||
Keeps student state for a particular XBlock usage and particular student.
|
||||
@@ -149,7 +151,7 @@ class StudentModule(models.Model):
|
||||
'state': str(self.state)[:20],
|
||||
},)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
@classmethod
|
||||
@@ -232,6 +234,7 @@ class BaseStudentModuleHistory(models.Model):
|
||||
return history_entries
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class StudentModuleHistory(BaseStudentModuleHistory):
|
||||
"""Keeps a complete history of state changes for a given XModule for a given
|
||||
Student. Right now, we restrict this to problems so that the table doesn't
|
||||
@@ -243,7 +246,7 @@ class StudentModuleHistory(BaseStudentModuleHistory):
|
||||
|
||||
student_module = models.ForeignKey(StudentModule, db_index=True, db_constraint=False, on_delete=models.CASCADE)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
def save_history(sender, instance, **kwargs): # pylint: disable=no-self-argument, unused-argument
|
||||
@@ -268,6 +271,7 @@ class StudentModuleHistory(BaseStudentModuleHistory):
|
||||
post_save.connect(save_history, sender=StudentModule)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class XBlockFieldBase(models.Model):
|
||||
"""
|
||||
Base class for all XBlock field storage.
|
||||
@@ -289,7 +293,7 @@ class XBlockFieldBase(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True, db_index=True)
|
||||
modified = models.DateTimeField(auto_now=True, db_index=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
keys = [field.name for field in self._meta.get_fields() if field.name not in ('created', 'modified')]
|
||||
return HTML(u'{}<{!r}').format(
|
||||
HTML(self.__class__.__name__),
|
||||
@@ -337,6 +341,7 @@ class XModuleStudentInfoField(XBlockFieldBase):
|
||||
student = models.ForeignKey(User, db_index=True, on_delete=models.CASCADE)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class OfflineComputedGrade(models.Model):
|
||||
"""
|
||||
Table of grades computed offline for a given user and course.
|
||||
@@ -355,10 +360,11 @@ class OfflineComputedGrade(models.Model):
|
||||
app_label = "courseware"
|
||||
unique_together = (('user', 'course_id'),)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[OfflineComputedGrade] %s: %s (%s) = %s" % (self.user, self.course_id, self.created, self.gradeset)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class OfflineComputedGradeLog(models.Model):
|
||||
"""
|
||||
Log of when offline grades are computed.
|
||||
@@ -377,7 +383,7 @@ class OfflineComputedGradeLog(models.Model):
|
||||
seconds = models.IntegerField(default=0) # seconds elapsed for computation
|
||||
nstudents = models.IntegerField(default=0)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[OCGLog] %s: %s" % (text_type(self.course_id), self.created)
|
||||
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ import six
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.dispatch import receiver
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from courseware.models import BaseStudentModuleHistory, StudentModule
|
||||
from courseware.fields import UnsignedBigIntAutoField
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class StudentModuleHistoryExtended(BaseStudentModuleHistory):
|
||||
"""Keeps a complete history of state changes for a given XModule for a given
|
||||
Student. Right now, we restrict this to problems so that the table doesn't
|
||||
@@ -64,5 +66,5 @@ class StudentModuleHistoryExtended(BaseStudentModuleHistory):
|
||||
"""
|
||||
StudentModuleHistoryExtended.objects.filter(student_module=instance).all().delete()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
@@ -5,9 +5,11 @@ from __future__ import absolute_import
|
||||
|
||||
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 EmailMarketingConfiguration(ConfigurationModel):
|
||||
"""
|
||||
Email marketing configuration
|
||||
@@ -166,6 +168,6 @@ class EmailMarketingConfiguration(ConfigurationModel):
|
||||
)
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"Email marketing configuration: New user list %s, Welcome template: %s" % \
|
||||
(self.sailthru_new_user_list, self.sailthru_welcome_template)
|
||||
|
||||
@@ -7,12 +7,15 @@ from __future__ import absolute_import
|
||||
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 six import text_type
|
||||
|
||||
from openedx.core.lib.cache_utils import request_cached
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PersistentGradesEnabledFlag(ConfigurationModel):
|
||||
"""
|
||||
Enables persistent grades across the platform.
|
||||
@@ -50,13 +53,14 @@ class PersistentGradesEnabledFlag(ConfigurationModel):
|
||||
class Meta(object):
|
||||
app_label = "grades"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
current_model = PersistentGradesEnabledFlag.current()
|
||||
return u"PersistentGradesEnabledFlag: enabled {}".format(
|
||||
current_model.is_enabled()
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CoursePersistentGradesFlag(ConfigurationModel):
|
||||
"""
|
||||
Enables persistent grades for a specific
|
||||
@@ -73,7 +77,7 @@ class CoursePersistentGradesFlag(ConfigurationModel):
|
||||
# The course that these features are attached to.
|
||||
course_id = CourseKeyField(max_length=255, db_index=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
not_en = "Not "
|
||||
if self.enabled:
|
||||
not_en = ""
|
||||
|
||||
@@ -9,6 +9,7 @@ from collections import OrderedDict, defaultdict
|
||||
import six
|
||||
from ccx_keys.locator import CCXLocator
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from lazy import lazy
|
||||
|
||||
from xmodule import block_metadata_utils
|
||||
@@ -19,6 +20,7 @@ from .subsection_grade import ZeroSubsectionGrade
|
||||
from .subsection_grade_factory import SubsectionGradeFactory
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseGradeBase(object):
|
||||
"""
|
||||
Base class for Course Grades.
|
||||
@@ -34,7 +36,7 @@ class CourseGradeBase(object):
|
||||
self.letter_grade = letter_grade or None
|
||||
self.force_update_subsections = force_update_subsections
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u'Course Grade: percent: {}, letter_grade: {}, passed: {}'.format(
|
||||
six.text_type(self.percent),
|
||||
self.letter_grade,
|
||||
|
||||
@@ -265,6 +265,7 @@ class VisibleBlocks(models.Model):
|
||||
return u"visible_blocks_cache.{}.{}".format(course_key, user_id)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PersistentSubsectionGrade(TimeStampedModel):
|
||||
"""
|
||||
A django model tracking persistent grades at the subsection level.
|
||||
@@ -336,7 +337,7 @@ class PersistentSubsectionGrade(TimeStampedModel):
|
||||
else:
|
||||
return self.usage_key
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""
|
||||
Returns a string representation of this model.
|
||||
"""
|
||||
@@ -507,6 +508,7 @@ class PersistentSubsectionGrade(TimeStampedModel):
|
||||
return u"subsection_grades_cache.{}".format(course_id)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PersistentCourseGrade(TimeStampedModel):
|
||||
"""
|
||||
A django model tracking persistent course grades.
|
||||
@@ -550,7 +552,7 @@ class PersistentCourseGrade(TimeStampedModel):
|
||||
|
||||
_CACHE_NAMESPACE = u"grades.models.PersistentCourseGrade"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""
|
||||
Returns a string representation of this model.
|
||||
"""
|
||||
@@ -643,6 +645,7 @@ 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.
|
||||
@@ -677,7 +680,7 @@ class PersistentSubsectionGradeOverride(models.Model):
|
||||
if 'grades' in apps.app_configs:
|
||||
history = HistoricalRecords()
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u', '.join([
|
||||
u"{}".format(type(self).__name__),
|
||||
u"earned_all_override: {}".format(self.earned_all_override),
|
||||
@@ -763,6 +766,7 @@ class PersistentSubsectionGradeOverride(models.Model):
|
||||
return cleaned_data
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PersistentSubsectionGradeOverrideHistory(models.Model):
|
||||
"""
|
||||
A django model tracking persistent grades override audit records.
|
||||
@@ -799,7 +803,7 @@ class PersistentSubsectionGradeOverrideHistory(models.Model):
|
||||
comments = models.CharField(max_length=300, blank=True, null=True)
|
||||
created = models.DateTimeField(auto_now_add=True, db_index=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""
|
||||
String representation of this model.
|
||||
"""
|
||||
|
||||
@@ -28,6 +28,7 @@ from django.conf import settings
|
||||
from django.contrib.auth.models import 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
|
||||
from six import text_type
|
||||
@@ -42,6 +43,7 @@ PROGRESS = 'PROGRESS'
|
||||
TASK_INPUT_LENGTH = 10000
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class InstructorTask(models.Model):
|
||||
"""
|
||||
Stores information about background tasks that have been submitted to
|
||||
@@ -91,7 +93,7 @@ class InstructorTask(models.Model):
|
||||
'task_output': self.task_output,
|
||||
},)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -15,6 +15,7 @@ import six
|
||||
from celery.states import READY_STATES, RETRY, SUCCESS
|
||||
from django.core.cache import cache
|
||||
from django.db import DatabaseError, transaction
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from six.moves import range, zip
|
||||
|
||||
from util.db import outer_atomic
|
||||
@@ -121,6 +122,7 @@ def _generate_items_for_subtask(
|
||||
TASK_LOG.info(u"Number of items generated by chunking %s not equal to original total %s", num_items_queued, total_num_items)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SubtaskStatus(object):
|
||||
"""
|
||||
Create and return a dict for tracking the status of a subtask.
|
||||
@@ -205,7 +207,7 @@ class SubtaskStatus(object):
|
||||
"""Return print representation of a SubtaskStatus object."""
|
||||
return 'SubtaskStatus<%r>' % (self.to_dict(),)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""Return unicode version of a SubtaskStatus object representation."""
|
||||
return six.text_type(repr(self))
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import absolute_import
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from . import utils
|
||||
from .mobile_platform import PLATFORM_CLASSES
|
||||
@@ -35,6 +36,7 @@ class MobileApiConfig(ConfigurationModel):
|
||||
return [profile.strip() for profile in cls.current().video_profiles.split(",") if profile]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class AppVersionConfig(models.Model):
|
||||
"""
|
||||
Configuration for mobile app versions available.
|
||||
@@ -64,7 +66,7 @@ class AppVersionConfig(models.Model):
|
||||
unique_together = ('platform', 'version',)
|
||||
ordering = ['-major_version', '-minor_version', '-patch_version']
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "{}_{}".format(self.platform, self.version)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -25,6 +25,7 @@ from django.db.models import Count, F, Q, Sum
|
||||
from django.db.models.signals import post_delete, post_save
|
||||
from django.dispatch import receiver
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from model_utils.managers import InheritanceManager
|
||||
@@ -786,6 +787,7 @@ class OrderItem(TimeStampedModel):
|
||||
self.save()
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Invoice(TimeStampedModel):
|
||||
"""
|
||||
This table capture all the information needed to support "invoicing"
|
||||
@@ -892,7 +894,7 @@ class Invoice(TimeStampedModel):
|
||||
],
|
||||
}
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
label = (
|
||||
six.text_type(self.internal_reference)
|
||||
if self.internal_reference
|
||||
@@ -1272,6 +1274,7 @@ class RegistrationCodeRedemption(models.Model):
|
||||
return code_redemption
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Coupon(models.Model):
|
||||
"""
|
||||
This table contains coupon codes
|
||||
@@ -1291,7 +1294,7 @@ class Coupon(models.Model):
|
||||
is_active = models.BooleanField(default=True)
|
||||
expiration_date = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[Coupon] code: {} course: {}".format(self.code, self.course_id)
|
||||
|
||||
@property
|
||||
@@ -1782,6 +1785,7 @@ class CourseRegCodeItem(OrderItem):
|
||||
return data
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseRegCodeItemAnnotation(models.Model):
|
||||
"""
|
||||
A model that maps course_id to an additional annotation. This is specifically needed because when Stanford
|
||||
@@ -1797,10 +1801,11 @@ class CourseRegCodeItemAnnotation(models.Model):
|
||||
course_id = CourseKeyField(unique=True, max_length=128, db_index=True)
|
||||
annotation = models.TextField(null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"{} : {}".format(text_type(self.course_id), self.annotation)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PaidCourseRegistrationAnnotation(models.Model):
|
||||
"""
|
||||
A model that maps course_id to an additional annotation. This is specifically needed because when Stanford
|
||||
@@ -1816,7 +1821,7 @@ class PaidCourseRegistrationAnnotation(models.Model):
|
||||
course_id = CourseKeyField(unique=True, max_length=128, db_index=True)
|
||||
annotation = models.TextField(null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"{} : {}".format(text_type(self.course_id), self.annotation)
|
||||
|
||||
|
||||
|
||||
@@ -245,12 +245,12 @@ class ItemizedPurchaseReportTest(ModuleStoreTestCase):
|
||||
|
||||
def test_paidcourseregistrationannotation_unicode(self):
|
||||
"""
|
||||
Fill in gap in test coverage. __unicode__ method of PaidCourseRegistrationAnnotation
|
||||
Fill in gap in test coverage. __str__ method of PaidCourseRegistrationAnnotation
|
||||
"""
|
||||
self.assertEqual(text_type(self.annotation), u'{} : {}'.format(text_type(self.course_key), self.TEST_ANNOTATION))
|
||||
|
||||
def test_courseregcodeitemannotationannotation_unicode(self):
|
||||
"""
|
||||
Fill in gap in test coverage. __unicode__ method of CourseRegCodeItemAnnotation
|
||||
Fill in gap in test coverage. __str__ method of CourseRegCodeItemAnnotation
|
||||
"""
|
||||
self.assertEqual(text_type(self.course_reg_code_annotation), u'{} : {}'.format(text_type(self.course_key), self.TEST_ANNOTATION))
|
||||
|
||||
@@ -592,7 +592,7 @@ class ShoppingCartViewsTests(SharedModuleStoreTestCase, XssTestMixin):
|
||||
coupon = Coupon(code='TestCode', description='testing', course_id=self.course_key,
|
||||
percentage_discount=12, created_by=self.user, is_active=True)
|
||||
coupon.save()
|
||||
self.assertEquals(coupon.__unicode__(), '[Coupon] code: TestCode course: MITx/999/Robot_Super_Course')
|
||||
self.assertEquals(str(coupon), '[Coupon] code: TestCode course: MITx/999/Robot_Super_Course')
|
||||
admin = User.objects.create_user('Mark', 'admin+courses@edx.org', 'foo')
|
||||
admin.is_staff = True
|
||||
get_coupon = Coupon.objects.get(id=1)
|
||||
|
||||
@@ -28,6 +28,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.files.base import ContentFile
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy
|
||||
@@ -144,6 +145,7 @@ class IDVerificationAttempt(StatusModel):
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ManualVerification(IDVerificationAttempt):
|
||||
"""
|
||||
Each ManualVerification represents a user's verification that bypasses the need for
|
||||
@@ -165,7 +167,7 @@ class ManualVerification(IDVerificationAttempt):
|
||||
class Meta(object):
|
||||
app_label = 'verify_student'
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return 'ManualIDVerification for {name}, status: {status}'.format(
|
||||
name=self.name,
|
||||
status=self.status,
|
||||
@@ -178,6 +180,7 @@ class ManualVerification(IDVerificationAttempt):
|
||||
return False
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class SSOVerification(IDVerificationAttempt):
|
||||
"""
|
||||
Each SSOVerification represents a Student's attempt to establish their identity
|
||||
@@ -215,7 +218,7 @@ class SSOVerification(IDVerificationAttempt):
|
||||
class Meta(object):
|
||||
app_label = "verify_student"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return 'SSOIDVerification for {name}, status: {status}'.format(
|
||||
name=self.name,
|
||||
status=self.status,
|
||||
|
||||
Reference in New Issue
Block a user