From 70e342a38dc58d4fa0db761720a2c1b18cbb593a Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 13 Oct 2017 11:56:28 +0100 Subject: [PATCH] Remove python_2_unicode_compatible decorators --- wagtail/contrib/postgres_search/backend.py | 3 +-- wagtail/contrib/postgres_search/models.py | 3 +-- wagtail/contrib/settings/context_processors.py | 4 ---- wagtail/tests/modeladmintest/models.py | 5 ----- wagtail/tests/snippets/models.py | 3 --- wagtail/tests/testapp/models.py | 4 ---- wagtail/wagtailadmin/widgets.py | 2 -- wagtail/wagtailcore/blocks/base.py | 3 +-- wagtail/wagtailcore/blocks/stream_block.py | 2 -- wagtail/wagtailcore/models.py | 7 ------- wagtail/wagtailcore/rich_text.py | 2 -- wagtail/wagtaildocs/models.py | 2 -- wagtail/wagtailembeds/blocks.py | 3 --- wagtail/wagtailembeds/models.py | 2 -- wagtail/wagtailforms/models.py | 2 -- wagtail/wagtailimages/models.py | 2 -- wagtail/wagtailsearch/models.py | 2 -- wagtail/wagtailusers/models.py | 2 -- 18 files changed, 3 insertions(+), 50 deletions(-) diff --git a/wagtail/contrib/postgres_search/backend.py b/wagtail/contrib/postgres_search/backend.py index 7a95e304d8..900507b7c9 100644 --- a/wagtail/contrib/postgres_search/backend.py +++ b/wagtail/contrib/postgres_search/backend.py @@ -7,7 +7,7 @@ from django.db import DEFAULT_DB_ALIAS, NotSupportedError, connections, transact from django.db.models import F, Manager, TextField, Value from django.db.models.constants import LOOKUP_SEP from django.db.models.functions import Cast -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.six import string_types from wagtail.wagtailsearch.backends.base import ( @@ -35,7 +35,6 @@ def get_pk_column(model): return model._meta.pk.get_attname_column()[1] -@python_2_unicode_compatible class Index(object): def __init__(self, backend, model, db_alias=None): self.backend = backend diff --git a/wagtail/contrib/postgres_search/models.py b/wagtail/contrib/postgres_search/models.py index 85d7105789..25b0c7384e 100644 --- a/wagtail/contrib/postgres_search/models.py +++ b/wagtail/contrib/postgres_search/models.py @@ -7,7 +7,7 @@ from django.db.models import ( CASCADE, AutoField, BigAutoField, BigIntegerField, F, ForeignKey, IntegerField, Model, QuerySet, TextField) from django.db.models.functions import Cast -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ from .utils import WEIGHTS_VALUES, get_descendants_content_types_pks @@ -47,7 +47,6 @@ class IndexQuerySet(QuerySet): return self.annotate_typed_pk().values_list('typed_pk', flat=True) -@python_2_unicode_compatible class IndexEntry(Model): content_type = ForeignKey(ContentType, on_delete=CASCADE) # We do not use an IntegerField since primary keys are not always integers. diff --git a/wagtail/contrib/settings/context_processors.py b/wagtail/contrib/settings/context_processors.py index 76e5ebaf0d..06af260346 100644 --- a/wagtail/contrib/settings/context_processors.py +++ b/wagtail/contrib/settings/context_processors.py @@ -1,11 +1,8 @@ from __future__ import absolute_import, unicode_literals -from django.utils.encoding import python_2_unicode_compatible - from .registry import registry -@python_2_unicode_compatible class SettingsProxy(dict): """ Get a SettingModuleProxy for an app using proxy['app_label'] @@ -21,7 +18,6 @@ class SettingsProxy(dict): return 'SettingsProxy' -@python_2_unicode_compatible class SettingModuleProxy(dict): """ Get a setting instance using proxy['modelname'] diff --git a/wagtail/tests/modeladmintest/models.py b/wagtail/tests/modeladmintest/models.py index 3ce685adce..b8a48308a6 100644 --- a/wagtail/tests/modeladmintest/models.py +++ b/wagtail/tests/modeladmintest/models.py @@ -1,13 +1,11 @@ from __future__ import absolute_import, unicode_literals from django.db import models -from django.utils.encoding import python_2_unicode_compatible from wagtail.wagtailcore.models import Page from wagtail.wagtailsearch import index -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=255) date_of_birth = models.DateField() @@ -23,7 +21,6 @@ class Author(models.Model): return '' -@python_2_unicode_compatible class Book(models.Model, index.Indexed): author = models.ForeignKey(Author, on_delete=models.PROTECT) title = models.CharField(max_length=255) @@ -33,7 +30,6 @@ class Book(models.Model, index.Indexed): return self.title -@python_2_unicode_compatible class Token(models.Model): key = models.CharField(max_length=40, primary_key=True) @@ -41,7 +37,6 @@ class Token(models.Model): return self.key -@python_2_unicode_compatible class Publisher(models.Model): name = models.CharField(max_length=50) headquartered_in = models.CharField(max_length=50, null=True, blank=True) diff --git a/wagtail/tests/snippets/models.py b/wagtail/tests/snippets/models.py index a9541bea08..624e19140c 100644 --- a/wagtail/tests/snippets/models.py +++ b/wagtail/tests/snippets/models.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, unicode_literals from django.db import models -from django.utils.encoding import python_2_unicode_compatible from modelcluster.fields import ParentalKey from modelcluster.models import ClusterableModel @@ -19,7 +18,6 @@ from .forms import FancySnippetForm # to ensure specific [in]correct register ordering # AlphaSnippet is registered during TestSnippetOrdering -@python_2_unicode_compatible class AlphaSnippet(models.Model): text = models.CharField(max_length=255) @@ -28,7 +26,6 @@ class AlphaSnippet(models.Model): # ZuluSnippet is registered during TestSnippetOrdering -@python_2_unicode_compatible class ZuluSnippet(models.Model): text = models.CharField(max_length=255) diff --git a/wagtail/tests/testapp/models.py b/wagtail/tests/testapp/models.py index 5a7ef5b32a..1000503b82 100644 --- a/wagtail/tests/testapp/models.py +++ b/wagtail/tests/testapp/models.py @@ -12,7 +12,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator from django.core.serializers.json import DjangoJSONEncoder from django.db import models from django.shortcuts import render -from django.utils.encoding import python_2_unicode_compatible from django.utils.six import text_type from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey, ParentalManyToManyField @@ -199,7 +198,6 @@ class EventPageSpeaker(Orderable, LinkFields): ] -@python_2_unicode_compatible class EventCategory(models.Model): name = models.CharField("Name", max_length=255) @@ -519,7 +517,6 @@ class AdvertTag(TaggedItemBase): content_object = ParentalKey('Advert', related_name='tagged_items', on_delete=models.CASCADE) -@python_2_unicode_compatible class Advert(ClusterableModel): url = models.URLField(null=True, blank=True) text = models.CharField(max_length=255) @@ -539,7 +536,6 @@ class Advert(ClusterableModel): register_snippet(Advert) -@python_2_unicode_compatible class AdvertWithTabbedInterface(models.Model): url = models.URLField(null=True, blank=True) text = models.CharField(max_length=255) diff --git a/wagtail/wagtailadmin/widgets.py b/wagtail/wagtailadmin/widgets.py index d3069e2883..90e1ed2153 100644 --- a/wagtail/wagtailadmin/widgets.py +++ b/wagtail/wagtailadmin/widgets.py @@ -9,7 +9,6 @@ from django.core.urlresolvers import reverse from django.forms import widgets from django.forms.utils import flatatt from django.template.loader import render_to_string -from django.utils.encoding import python_2_unicode_compatible from django.utils.formats import get_format from django.utils.functional import cached_property from django.utils.html import format_html @@ -217,7 +216,6 @@ class AdminPageChooser(AdminChooser): ) -@python_2_unicode_compatible @total_ordering class Button(object): show = True diff --git a/wagtail/wagtailcore/blocks/base.py b/wagtail/wagtailcore/blocks/base.py index 74ff8b3254..7cca2ce5a6 100644 --- a/wagtail/wagtailcore/blocks/base.py +++ b/wagtail/wagtailcore/blocks/base.py @@ -8,7 +8,7 @@ from django.core import checks from django.core.exceptions import ImproperlyConfigured from django.template.loader import render_to_string from django.utils import six -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.safestring import mark_safe from django.utils.text import capfirst @@ -411,7 +411,6 @@ class Block(six.with_metaclass(BaseBlock, object)): __hash__ = None -@python_2_unicode_compatible class BoundBlock(object): def __init__(self, block, value, prefix=None, errors=None): self.block = block diff --git a/wagtail/wagtailcore/blocks/stream_block.py b/wagtail/wagtailcore/blocks/stream_block.py index 296fe9afd3..00a0534e25 100644 --- a/wagtail/wagtailcore/blocks/stream_block.py +++ b/wagtail/wagtailcore/blocks/stream_block.py @@ -10,7 +10,6 @@ from django.forms.utils import ErrorList from django.template.loader import render_to_string # Must be imported from Django so we get the new implementation of with_metaclass from django.utils import six -from django.utils.encoding import python_2_unicode_compatible from django.utils.html import format_html_join from django.utils.safestring import mark_safe from django.utils.translation import ugettext as _ @@ -326,7 +325,6 @@ class StreamBlock(six.with_metaclass(DeclarativeSubBlocksMetaclass, BaseStreamBl pass -@python_2_unicode_compatible # provide equivalent __unicode__ and __str__ methods on Py2 class StreamValue(collections.Sequence): """ Custom type used to represent the value of a StreamBlock; behaves as a sequence of BoundBlocks diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index 22d2704d9a..4a49ebf821 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -21,7 +21,6 @@ from django.http import Http404 from django.template.response import TemplateResponse # Must be imported from Django so we get the new implementation of with_metaclass from django.utils import six, timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property from django.utils.six import StringIO from django.utils.six.moves.urllib.parse import urlparse @@ -48,7 +47,6 @@ class SiteManager(models.Manager): return self.get(hostname=hostname, port=port) -@python_2_unicode_compatible class Site(models.Model): hostname = models.CharField(verbose_name=_('hostname'), max_length=255, db_index=True) port = models.IntegerField( @@ -243,7 +241,6 @@ class AbstractPage(MP_Node): abstract = True -@python_2_unicode_compatible class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, ClusterableModel)): title = models.CharField( verbose_name=_('title'), @@ -1407,7 +1404,6 @@ class SubmittedRevisionsManager(models.Manager): return super(SubmittedRevisionsManager, self).get_queryset().filter(submitted_for_moderation=True) -@python_2_unicode_compatible class PageRevision(models.Model): page = models.ForeignKey('Page', verbose_name=_('page'), related_name='revisions', on_delete=models.CASCADE) submitted_for_moderation = models.BooleanField( @@ -1560,7 +1556,6 @@ PAGE_PERMISSION_TYPE_CHOICES = [ ] -@python_2_unicode_compatible class GroupPagePermission(models.Model): group = models.ForeignKey(Group, verbose_name=_('group'), related_name='page_permissions', on_delete=models.CASCADE) page = models.ForeignKey('Page', verbose_name=_('page'), related_name='group_permissions', on_delete=models.CASCADE) @@ -1945,7 +1940,6 @@ class CollectionViewRestriction(BaseViewRestriction): verbose_name_plural = _('collection view restrictions') -@python_2_unicode_compatible class Collection(MP_Node): """ A location in which resources such as images and documents can be grouped @@ -2005,7 +1999,6 @@ class CollectionMember(models.Model): abstract = True -@python_2_unicode_compatible class GroupCollectionPermission(models.Model): """ A rule indicating that a group has permission for some action (e.g. "create document") diff --git a/wagtail/wagtailcore/rich_text.py b/wagtail/wagtailcore/rich_text.py index d606e205fd..333c37dc51 100644 --- a/wagtail/wagtailcore/rich_text.py +++ b/wagtail/wagtailcore/rich_text.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals import re # parsing HTML with regexes LIKE A BOSS. -from django.utils.encoding import python_2_unicode_compatible from django.utils.html import escape from django.utils.safestring import mark_safe @@ -182,7 +181,6 @@ def expand_db_html(html, for_editor=False): return html -@python_2_unicode_compatible class RichText(object): """ A custom object used to represent a renderable rich text value. diff --git a/wagtail/wagtaildocs/models.py b/wagtail/wagtaildocs/models.py index 8db6cec684..dc8ddfe273 100644 --- a/wagtail/wagtaildocs/models.py +++ b/wagtail/wagtaildocs/models.py @@ -7,7 +7,6 @@ from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse from django.db import models from django.dispatch import Signal -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from taggit.managers import TaggableManager @@ -21,7 +20,6 @@ class DocumentQuerySet(SearchableQuerySetMixin, models.QuerySet): pass -@python_2_unicode_compatible class AbstractDocument(CollectionMember, index.Indexed, models.Model): title = models.CharField(max_length=255, verbose_name=_('title')) file = models.FileField(upload_to='documents', verbose_name=_('file')) diff --git a/wagtail/wagtailembeds/blocks.py b/wagtail/wagtailembeds/blocks.py index 81bbe7e3fc..c50df81e72 100644 --- a/wagtail/wagtailembeds/blocks.py +++ b/wagtail/wagtailembeds/blocks.py @@ -1,12 +1,9 @@ from __future__ import absolute_import, unicode_literals -from django.utils.encoding import python_2_unicode_compatible - from wagtail.wagtailcore import blocks from wagtail.wagtailembeds.format import embed_to_frontend_html -@python_2_unicode_compatible class EmbedValue(object): """ Native value of an EmbedBlock. Should, at minimum, have a 'url' property diff --git a/wagtail/wagtailembeds/models.py b/wagtail/wagtailembeds/models.py index 08c6065310..4545d37a95 100644 --- a/wagtail/wagtailembeds/models.py +++ b/wagtail/wagtailembeds/models.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, division, unicode_literals from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ EMBED_TYPES = ( @@ -12,7 +11,6 @@ EMBED_TYPES = ( ) -@python_2_unicode_compatible class Embed(models.Model): """ When embed code is fetched from a provider (eg, youtube) we cache that code diff --git a/wagtail/wagtailforms/models.py b/wagtail/wagtailforms/models.py index 9165b131eb..14bfb0ceee 100644 --- a/wagtail/wagtailforms/models.py +++ b/wagtail/wagtailforms/models.py @@ -7,7 +7,6 @@ from django.contrib.contenttypes.models import ContentType from django.core.serializers.json import DjangoJSONEncoder from django.db import models from django.shortcuts import render -from django.utils.encoding import python_2_unicode_compatible from django.utils.six import text_type from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ @@ -36,7 +35,6 @@ FORM_FIELD_CHOICES = ( ) -@python_2_unicode_compatible class AbstractFormSubmission(models.Model): """ Data for a form submission. diff --git a/wagtail/wagtailimages/models.py b/wagtail/wagtailimages/models.py index ed5d5002ba..256cd60f73 100644 --- a/wagtail/wagtailimages/models.py +++ b/wagtail/wagtailimages/models.py @@ -11,7 +11,6 @@ from django.core.files import File from django.core.urlresolvers import reverse from django.db import models from django.forms.utils import flatatt -from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.six import BytesIO, string_types, text_type @@ -62,7 +61,6 @@ def get_rendition_upload_to(instance, filename): return instance.get_upload_to(filename) -@python_2_unicode_compatible class AbstractImage(CollectionMember, index.Indexed, models.Model): title = models.CharField(max_length=255, verbose_name=_('title')) file = models.ImageField( diff --git a/wagtail/wagtailsearch/models.py b/wagtail/wagtailsearch/models.py index b87f27ab6c..38146cdc84 100644 --- a/wagtail/wagtailsearch/models.py +++ b/wagtail/wagtailsearch/models.py @@ -5,13 +5,11 @@ import datetime from django.conf import settings from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from wagtail.wagtailsearch.utils import MAX_QUERY_STRING_LENGTH, normalise_query_string -@python_2_unicode_compatible class Query(models.Model): query_string = models.CharField(max_length=MAX_QUERY_STRING_LENGTH, unique=True) diff --git a/wagtail/wagtailusers/models.py b/wagtail/wagtailusers/models.py index 00a034d50d..f3ebf6f427 100644 --- a/wagtail/wagtailusers/models.py +++ b/wagtail/wagtailusers/models.py @@ -2,11 +2,9 @@ from __future__ import absolute_import, unicode_literals 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 _ -@python_2_unicode_compatible class UserProfile(models.Model): user = models.OneToOneField( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='wagtail_userprofile'