Commit 9512f287 authored by fred's avatar fred

mark models with @python_2_unicode_compatible

parent 3dfdf997
......@@ -7,6 +7,7 @@ from django.forms import fields
from django.core.urlresolvers import reverse
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
......@@ -50,6 +51,7 @@ class WeekdayMixin(object):
return week_day == day
@python_2_unicode_compatible
class Category(models.Model):
class Meta:
......@@ -64,10 +66,11 @@ class Category(models.Model):
def sorted_emission(self):
return self.emission_set.order_by('title')
def __unicode__(self):
def __str__(self):
return self.title
@python_2_unicode_compatible
class Colour(models.Model):
class Meta:
......@@ -81,10 +84,11 @@ class Colour(models.Model):
def sorted_emission(self):
return self.emission_set.order_by('title')
def __unicode__(self):
def __str__(self):
return self.title
@python_2_unicode_compatible
class Format(models.Model):
class Meta:
......@@ -95,7 +99,7 @@ class Format(models.Model):
title = models.CharField(_('Title'), max_length=50)
slug = models.SlugField(null=True)
def __unicode__(self):
def __str__(self):
return self.title
......@@ -104,6 +108,7 @@ def get_emission_image_path(instance, filename):
os.path.basename(filename))
@python_2_unicode_compatible
class Emission(models.Model):
class Meta:
......@@ -144,7 +149,7 @@ class Emission(models.Model):
def get_absolute_url(self):
return reverse('emission-view', kwargs={'slug': str(self.slug)})
def __unicode__(self):
def __str__(self):
return self.title
def save(self, *args, **kwargs):
......@@ -186,6 +191,7 @@ class Emission(models.Model):
return possible_dates[0]
@python_2_unicode_compatible
class Schedule(models.Model, WeekdayMixin):
class Meta:
......@@ -274,7 +280,7 @@ class Schedule(models.Model, WeekdayMixin):
return possible_dates[0]
def __unicode__(self):
def __str__(self):
return u'%s at %s' % (self.emission.title,
self.datetime.strftime('%a %H:%M'))
......@@ -284,6 +290,7 @@ def get_episode_image_path(instance, filename):
os.path.basename(filename))
@python_2_unicode_compatible
class Episode(models.Model):
class Meta:
......@@ -315,7 +322,7 @@ class Episode(models.Model):
# XXX: languages (models.ManyToManyField(Language))
def __unicode__(self):
def __str__(self):
return self.title
def save(self, *args, **kwargs):
......@@ -386,6 +393,7 @@ class Episode(models.Model):
return Diffusion.objects.filter(episode=self.id).order_by('datetime')
@python_2_unicode_compatible
class Diffusion(models.Model, WeekdayMixin):
class Meta:
......@@ -395,7 +403,7 @@ class Diffusion(models.Model, WeekdayMixin):
episode = models.ForeignKey('Episode', verbose_name=_('Episode'))
datetime = models.DateTimeField(_('Date/time'), db_index=True)
def __unicode__(self):
def __str__(self):
return u'%s at %02d:%02d' % (self.episode.title, self.datetime.hour,
self.datetime.minute)
......@@ -406,6 +414,7 @@ class Diffusion(models.Model, WeekdayMixin):
return self.datetime + datetime.timedelta(minutes=self.get_duration())
@python_2_unicode_compatible
class Absence(models.Model):
class Meta:
......@@ -415,7 +424,7 @@ class Absence(models.Model):
emission = models.ForeignKey('Emission', verbose_name=u'Emission')
datetime = models.DateTimeField(_('Date/time'), db_index=True)
def __unicode__(self):
def __str__(self):
return u'Absence for %s on %s' % (self.emission.title, self.datetime)
......@@ -423,6 +432,8 @@ def get_sound_path(instance, filename):
return os.path.join('sounds.orig', instance.episode.emission.slug,
os.path.basename(filename))
@python_2_unicode_compatible
class SoundFile(models.Model):
class Meta:
......@@ -472,10 +483,11 @@ class SoundFile(models.Model):
return ''
return '%d:%02d' % (self.duration/60, self.duration%60)
def __unicode__(self):
def __str__(self):
return '%s - %s' % (self.title or self.id, self.episode.title)
@python_2_unicode_compatible
class NewsCategory(models.Model):
class Meta:
......@@ -486,7 +498,7 @@ class NewsCategory(models.Model):
title = models.CharField(_('Title'), max_length=50)
slug = models.SlugField(null=True)
def __unicode__(self):
def __str__(self):
return self.title
def get_sorted_newsitems(self):
......@@ -498,6 +510,7 @@ def get_newsitem_image_path(instance, filename):
os.path.basename(filename))
@python_2_unicode_compatible
class NewsItem(models.Model):
class Meta:
......@@ -528,13 +541,14 @@ class NewsItem(models.Model):
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
last_update_timestamp = models.DateTimeField(auto_now=True, null=True)
def __unicode__(self):
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('newsitem-view', kwargs={'slug': str(self.slug)})
@python_2_unicode_compatible
class Nonstop(models.Model):
class Meta:
......@@ -550,10 +564,11 @@ class Nonstop(models.Model):
text = RichTextField(_('Description'), null=True, blank=True)
redirect_path = models.CharField(_('Redirect Path'), max_length=200, blank=True)
def __unicode__(self):
def __str__(self):
return self.title
@python_2_unicode_compatible
class Focus(models.Model):
title = models.CharField(_('Alternate Title'), max_length=50,
null=True, blank=True)
......@@ -572,7 +587,7 @@ class Focus(models.Model):
creation_timestamp = models.DateTimeField(auto_now_add=True, null=True)
last_update_timestamp = models.DateTimeField(auto_now=True, null=True)
def __unicode__(self):
def __str__(self):
if self.newsitem:
return u'Newsitem: %s' % self.newsitem.title
if self.emission:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment