BOM Project
Updated __unicode__ to __str__
This commit is contained in:
@@ -14,6 +14,7 @@ from django.core.validators import validate_comma_separated_integer_list
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.dispatch import receiver
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from edx_django_utils.cache import RequestCache
|
||||
@@ -38,6 +39,7 @@ Mode = namedtuple('Mode',
|
||||
])
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseMode(models.Model):
|
||||
"""
|
||||
We would like to offer a course in a variety of modes.
|
||||
@@ -791,7 +793,7 @@ class CourseMode(models.Model):
|
||||
self.bulk_sku
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u"{} : {}, min={}".format(
|
||||
self.course_id, self.mode_slug, self.min_price
|
||||
)
|
||||
@@ -902,6 +904,7 @@ class CourseModesArchive(models.Model):
|
||||
expiration_datetime = models.DateTimeField(default=None, null=True, blank=True)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseModeExpirationConfig(ConfigurationModel):
|
||||
"""
|
||||
Configuration for time period from end of course to auto-expire a course mode.
|
||||
@@ -918,6 +921,6 @@ class CourseModeExpirationConfig(ConfigurationModel):
|
||||
)
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
""" Returns the unicode date of the verification window. """
|
||||
return six.text_type(self.verification_window)
|
||||
|
||||
@@ -9,6 +9,7 @@ from datetime import timedelta
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.db import IntegrityError, models, transaction
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.timezone import now
|
||||
from model_utils import Choices
|
||||
from model_utils.models import TimeStampedModel
|
||||
@@ -26,6 +27,7 @@ from util.date_utils import strftime_localized
|
||||
log = logging.getLogger("common.entitlements.models")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseEntitlementPolicy(models.Model):
|
||||
"""
|
||||
Represents the Entitlement's policy for expiration, refunds, and regaining a used certificate
|
||||
@@ -138,7 +140,7 @@ class CourseEntitlementPolicy(models.Model):
|
||||
and not entitlement.enrollment_course_run
|
||||
and not entitlement.expired_at)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return u'Course Entitlement Policy: expiration_period: {}, refund_period: {}, regain_period: {}, mode: {}'\
|
||||
.format(
|
||||
self.expiration_period,
|
||||
@@ -448,6 +450,7 @@ class CourseEntitlement(TimeStampedModel):
|
||||
raise IntegrityError
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseEntitlementSupportDetail(TimeStampedModel):
|
||||
"""
|
||||
Table recording support interactions with an entitlement
|
||||
@@ -492,7 +495,7 @@ class CourseEntitlementSupportDetail(TimeStampedModel):
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""Unicode representation of an Entitlement"""
|
||||
return u'Course Entitlement Support Detail: entitlement: {}, support_user: {}, reason: {}'.format(
|
||||
self.entitlement,
|
||||
|
||||
@@ -9,8 +9,10 @@ from six.moves import map
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db.models.fields import TextField
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class AssetBaseUrlConfig(ConfigurationModel):
|
||||
"""
|
||||
Configuration for the base URL used for static assets.
|
||||
@@ -34,10 +36,11 @@ class AssetBaseUrlConfig(ConfigurationModel):
|
||||
def __repr__(self):
|
||||
return '<AssetBaseUrlConfig(base_url={})>'.format(self.get_base_url())
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class AssetExcludedExtensionsConfig(ConfigurationModel):
|
||||
"""
|
||||
Configuration for the the excluded file extensions when canonicalizing static asset paths.
|
||||
@@ -63,5 +66,5 @@ class AssetExcludedExtensionsConfig(ConfigurationModel):
|
||||
def __repr__(self):
|
||||
return '<AssetExcludedExtensionsConfig(extensions={})>'.format(self.get_excluded_extensions())
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(repr(self))
|
||||
|
||||
@@ -10,11 +10,13 @@ from config_models.models import ConfigurationModel
|
||||
from django.contrib import admin
|
||||
from django.core.cache import cache
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
|
||||
from openedx.core.djangolib.markup import HTML
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class GlobalStatusMessage(ConfigurationModel):
|
||||
"""
|
||||
Model that represents the current status message.
|
||||
@@ -51,10 +53,11 @@ class GlobalStatusMessage(ConfigurationModel):
|
||||
cache.set(cache_key, msg)
|
||||
return msg
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "{} - {} - {}".format(self.change_date, self.enabled, self.message)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CourseMessage(models.Model):
|
||||
"""
|
||||
Model that allows the administrator to specify banner messages for individual courses.
|
||||
@@ -68,7 +71,7 @@ class CourseMessage(models.Model):
|
||||
course_key = CourseKeyField(max_length=255, blank=True, db_index=True)
|
||||
message = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return six.text_type(self.course_key)
|
||||
|
||||
|
||||
|
||||
@@ -858,7 +858,7 @@ EVENT_NAME_ENROLLMENT_DEACTIVATED = 'edx.course.enrollment.deactivated'
|
||||
EVENT_NAME_ENROLLMENT_MODE_CHANGED = 'edx.course.enrollment.mode_changed'
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
@python_2_unicode_compatible
|
||||
class LoginFailures(models.Model):
|
||||
"""
|
||||
This model will keep track of failed login attempts.
|
||||
@@ -1084,6 +1084,7 @@ class CourseEnrollmentManager(models.Manager):
|
||||
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
|
||||
@@ -1160,7 +1161,7 @@ class CourseEnrollment(models.Model):
|
||||
# When the property .course_overview is accessed for the first time, this variable will be set.
|
||||
self._course_overview = None
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return (
|
||||
"[CourseEnrollment] {}: {} ({}); active: ({})"
|
||||
).format(self.user, self.course_id, self.created, self.is_active)
|
||||
@@ -2139,6 +2140,7 @@ class ManualEnrollmentAudit(models.Model):
|
||||
return cls.objects.filter(id__in=manual_enrollment_ids).update(reason="", enrolled_email=retired_email)
|
||||
|
||||
|
||||
@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.
|
||||
@@ -2166,7 +2168,7 @@ class CourseEnrollmentAllowed(DeletableByUserValue, models.Model):
|
||||
class Meta(object):
|
||||
unique_together = (('email', 'course_id'),)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[CourseEnrollmentAllowed] %s: %s (%s)" % (self.email, self.course_id, self.created)
|
||||
|
||||
@classmethod
|
||||
@@ -2199,6 +2201,7 @@ 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.
|
||||
@@ -2244,7 +2247,7 @@ class CourseAccessRole(models.Model):
|
||||
"""
|
||||
return self._key < other._key # pylint: disable=protected-access
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[CourseAccessRole] user: {} role: {} org: {} course: {}".format(self.user.username, self.role, self.org, self.course_id)
|
||||
|
||||
|
||||
@@ -2576,6 +2579,7 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
|
||||
)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class EntranceExamConfiguration(models.Model):
|
||||
"""
|
||||
Represents a Student's entrance exam specific data for a single Course
|
||||
@@ -2595,7 +2599,7 @@ class EntranceExamConfiguration(models.Model):
|
||||
class Meta(object):
|
||||
unique_together = (('user', 'course_id'), )
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "[EntranceExamConfiguration] %s: %s (%s) = %s" % (
|
||||
self.user, self.course_id, self.created, self.skip_entrance_exam
|
||||
)
|
||||
@@ -2683,6 +2687,7 @@ class SocialLink(models.Model): # pylint: disable=model-missing-unicode
|
||||
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.
|
||||
@@ -2703,7 +2708,7 @@ class CourseEnrollmentAttribute(models.Model):
|
||||
help_text=_("Value of the enrollment attribute")
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""Unicode representation of the attribute. """
|
||||
return u"{namespace}:{name}, {value}".format(
|
||||
namespace=self.namespace,
|
||||
@@ -2790,6 +2795,7 @@ class EnrollmentRefundConfiguration(ConfigurationModel):
|
||||
self.refund_window_microseconds = int(refund_window.total_seconds() * 1000000)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class RegistrationCookieConfiguration(ConfigurationModel):
|
||||
"""
|
||||
Configuration for registration cookies.
|
||||
@@ -2806,7 +2812,7 @@ class RegistrationCookieConfiguration(ConfigurationModel):
|
||||
help_text=_("Name of the affiliate cookie")
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""Unicode representation of this config. """
|
||||
return u"UTM: {utm_name}; AFFILIATE: {affiliate_name}".format(
|
||||
utm_name=self.utm_cookie_name,
|
||||
@@ -2858,6 +2864,7 @@ class UserAttribute(TimeStampedModel):
|
||||
return None
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class LogoutViewConfiguration(ConfigurationModel):
|
||||
"""
|
||||
DEPRECATED: Configuration for the logout view.
|
||||
@@ -2865,7 +2872,7 @@ class LogoutViewConfiguration(ConfigurationModel):
|
||||
.. no_pii:
|
||||
"""
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
"""
|
||||
Unicode representation of the instance.
|
||||
"""
|
||||
|
||||
@@ -12,6 +12,7 @@ from __future__ import absolute_import
|
||||
import logging
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
from track.backends import BaseBackend
|
||||
|
||||
@@ -31,6 +32,7 @@ LOGFIELDS = [
|
||||
]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class TrackingLog(models.Model):
|
||||
"""
|
||||
Defines the fields that are stored in the tracking log database.
|
||||
@@ -55,7 +57,7 @@ class TrackingLog(models.Model):
|
||||
app_label = 'track'
|
||||
db_table = 'track_trackinglog'
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
fmt = (
|
||||
u"[{self.time}] {self.username}@{self.ip}: "
|
||||
u"{self.event_source}| {self.event_type} | "
|
||||
|
||||
@@ -7,8 +7,10 @@ from __future__ import absolute_import
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class XBlockConfiguration(ConfigurationModel):
|
||||
"""
|
||||
XBlock configuration used by both LMS and Studio, and not specific to a particular template.
|
||||
@@ -28,12 +30,13 @@ class XBlockConfiguration(ConfigurationModel):
|
||||
verbose_name=_('show deprecation messaging in Studio')
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return (
|
||||
"XBlockConfiguration(name={}, enabled={}, deprecated={})"
|
||||
).format(self.name, self.enabled, self.deprecated)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class XBlockStudioConfigurationFlag(ConfigurationModel):
|
||||
"""
|
||||
Enables site-wide Studio configuration for XBlocks.
|
||||
@@ -46,10 +49,11 @@ class XBlockStudioConfigurationFlag(ConfigurationModel):
|
||||
|
||||
# boolean field 'enabled' inherited from parent ConfigurationModel
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return "XBlockStudioConfigurationFlag(enabled={})".format(self.enabled)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class XBlockStudioConfiguration(ConfigurationModel):
|
||||
"""
|
||||
Studio editing configuration for a specific XBlock/template combination.
|
||||
@@ -76,7 +80,7 @@ class XBlockStudioConfiguration(ConfigurationModel):
|
||||
class Meta(object):
|
||||
app_label = "xblock_django"
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return (
|
||||
"XBlockStudioConfiguration(name={}, template={}, enabled={}, support_level={})"
|
||||
).format(self.name, self.template, self.enabled, self.support_level)
|
||||
|
||||
Reference in New Issue
Block a user