python3: use @python_2_unicode_compatible on classes
This commit is contained in:
parent
1bd5333cb5
commit
578492612b
|
@ -35,6 +35,7 @@ from django.utils import timezone, dateparse
|
|||
from django.core.mail import EmailMultiAlternatives
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.formats import localize
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
|
@ -84,6 +85,7 @@ def build_remote_item(data, regie):
|
|||
no_online_payment_reason=data.get('no_online_payment_reason'))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Regie(models.Model):
|
||||
label = models.CharField(verbose_name=_('Label'), max_length=64)
|
||||
slug = models.SlugField(unique=True, verbose_name=_('Identifier'),
|
||||
|
@ -127,7 +129,7 @@ class Regie(models.Model):
|
|||
def natural_key(self):
|
||||
return (self.slug,)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
def get_text_on_success(self):
|
||||
|
|
|
@ -18,6 +18,7 @@ import json
|
|||
|
||||
from django.core import serializers
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.text import slugify
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
|
@ -88,6 +89,7 @@ class MapLayerManager(models.Manager):
|
|||
return self.get(slug=slug)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MapLayer(models.Model):
|
||||
objects = MapLayerManager()
|
||||
|
||||
|
@ -123,7 +125,7 @@ class MapLayer(models.Model):
|
|||
self.slug = slug
|
||||
super(MapLayer, self).save(*args, **kwargs)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
def natural_key(self):
|
||||
|
|
|
@ -18,6 +18,7 @@ import re
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.timezone import now, timedelta
|
||||
from django.db.models import Q
|
||||
|
@ -61,6 +62,7 @@ class NotificationQuerySet(QuerySet):
|
|||
end_timestamp=past_end_timestamp, acked=True)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Notification(models.Model):
|
||||
ID_RE = r'^[\w-]+:[\w-]+$'
|
||||
|
||||
|
@ -82,7 +84,7 @@ class Notification(models.Model):
|
|||
('user', 'external_id'),
|
||||
)
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.summary
|
||||
|
||||
@property
|
||||
|
|
|
@ -41,6 +41,7 @@ from django import forms
|
|||
from django import template
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six.moves.urllib.parse import urlparse
|
||||
|
@ -117,6 +118,7 @@ class PageManager(models.Manager):
|
|||
return queryset.filter(snapshot__isnull=True)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Page(models.Model):
|
||||
objects = PageManager()
|
||||
snapshots = PageManager(snapshots=True)
|
||||
|
@ -150,7 +152,7 @@ class Page(models.Model):
|
|||
class Meta:
|
||||
ordering = ['order']
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def natural_key(self):
|
||||
|
@ -463,6 +465,7 @@ class CellMeta(MediaDefiningClass, ModelBase):
|
|||
pass
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CellBase(six.with_metaclass(CellMeta, models.Model)):
|
||||
|
||||
page = models.ForeignKey(Page)
|
||||
|
@ -499,8 +502,8 @@ class CellBase(six.with_metaclass(CellMeta, models.Model)):
|
|||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __unicode__(self):
|
||||
label = unicode(self.get_verbose_name())
|
||||
def __str__(self):
|
||||
label = self.get_verbose_name()
|
||||
additional_label = self.get_additional_label()
|
||||
if label and additional_label:
|
||||
return '%s (%s)' % (label, re.sub(r'\r?\n', ' ', force_text(additional_label)))
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
from django.contrib.auth.models import Group
|
||||
from django.db import transaction
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from combo.apps.assets.models import Asset
|
||||
|
@ -23,11 +24,12 @@ from combo.apps.maps.models import MapLayer
|
|||
from .models import Page
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MissingGroups(Exception):
|
||||
def __init__(self, names):
|
||||
self.names = names
|
||||
|
||||
def __unicode__(self):
|
||||
def __str__(self):
|
||||
return _('Missing groups: %s') % ', '.join(self.names)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue