Merge pull request #21735 from edx/BOM-update_str_method

BOM Project __unicode__ to __str__
This commit is contained in:
Ayub
2019-09-26 10:47:14 +05:00
committed by GitHub
62 changed files with 306 additions and 142 deletions

View File

@@ -8,6 +8,7 @@ from django.db import models
from django.db.models.signals import post_init, post_save
from django.dispatch import Signal, receiver
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
# A signal that will be sent when users should be added or removed from the creator group
@@ -20,6 +21,7 @@ send_admin_notification = Signal(providing_args=["user"])
send_user_notification = Signal(providing_args=["user", "state"])
@python_2_unicode_compatible
class CourseCreator(models.Model):
"""
Creates the database table model.
@@ -47,7 +49,7 @@ class CourseCreator(models.Model):
note = models.CharField(max_length=512, blank=True, help_text=_("Optional notes about this user (for example, "
"why course creation access was denied)"))
def __unicode__(self):
def __str__(self):
return u"{0} | {1} [{2}]".format(self.user, self.state, self.state_changed)

View File

@@ -10,6 +10,7 @@ from __future__ import absolute_import
import six
from config_models.models import ConfigurationModel
from django.db.models import TextField
from django.utils.encoding import python_2_unicode_compatible
from opaque_keys.edx.django.models import CourseKeyField
from openedx.core.lib.cache_utils import request_cached
@@ -37,6 +38,7 @@ class StudioConfig(ConfigurationModel):
# TODO: Move CourseEditLTIFieldsEnabledFlag to LTI XBlock as a part of EDUCATOR-121
# reference: https://openedx.atlassian.net/browse/EDUCATOR-121
@python_2_unicode_compatible
class CourseEditLTIFieldsEnabledFlag(ConfigurationModel):
"""
Enables the editing of "request username" and "request email" fields
@@ -77,7 +79,7 @@ class CourseEditLTIFieldsEnabledFlag(ConfigurationModel):
return course_specific_config.enabled if course_specific_config else False
def __unicode__(self):
def __str__(self):
en = "Not "
if self.enabled:
en = ""

View File

@@ -4,8 +4,10 @@ Django Model for tags
from __future__ import absolute_import
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class TagCategories(models.Model):
"""
This model represents tag categories.
@@ -21,7 +23,7 @@ class TagCategories(models.Model):
verbose_name = "tag category"
verbose_name_plural = "tag categories"
def __unicode__(self):
def __str__(self):
return "[TagCategories] {}: {}".format(self.name, self.title)
def get_values(self):
@@ -31,6 +33,7 @@ class TagCategories(models.Model):
return [t.value for t in TagAvailableValues.objects.filter(category=self)]
@python_2_unicode_compatible
class TagAvailableValues(models.Model):
"""
This model represents available values for tags.
@@ -45,5 +48,5 @@ class TagAvailableValues(models.Model):
ordering = ('id',)
verbose_name = "available tag value"
def __unicode__(self):
def __str__(self):
return "[TagAvailableValues] {}: {}".format(self.category, self.value)