Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

Commit

Permalink
Ensure courseware models allow unicode rendering (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
pomegranited authored Apr 12, 2020
1 parent 30eb6f2 commit 7fc57cc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lms/djangoapps/courseware/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,14 @@ class Meta(object):
student_module = models.ForeignKey(StudentModule, db_index=True)

def __unicode__(self):
return unicode(repr(self))
return u'{}<{!r}'.format(
self.__class__.__name__,
{
key: unicode(getattr(self, key))
for key in self._meta.get_all_field_names()
if key not in ('created', 'modified')
}
)

def save_history(sender, instance, **kwargs): # pylint: disable=no-self-argument, unused-argument
"""
Expand Down Expand Up @@ -256,7 +263,7 @@ def __unicode__(self):
return u'{}<{!r}'.format(
self.__class__.__name__,
{
key: getattr(self, key)
key: unicode(getattr(self, key))
for key in self._meta.get_all_field_names()
if key not in ('created', 'modified')
}
Expand Down Expand Up @@ -317,7 +324,7 @@ class Meta(object):
unique_together = (('user', 'course_id'), )

def __unicode__(self):
return "[OfflineComputedGrade] %s: %s (%s) = %s" % (self.user, self.course_id, self.created, self.gradeset)
return u"[OfflineComputedGrade] %s: %s (%s) = %s" % (self.user, self.course_id, self.created, self.gradeset)


class OfflineComputedGradeLog(models.Model):
Expand Down

0 comments on commit 7fc57cc

Please sign in to comment.