kopia lustrzana https://github.com/wagtail/wagtail
Make Filter a plain Python object instead of a model
rodzic
e1a30b1aad
commit
6ae020c0ef
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-02-08 23:51
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailimages', '0018_remove_rendition_filter'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.DeleteModel(
|
||||
name='Filter',
|
||||
),
|
||||
]
|
|
@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
import hashlib
|
||||
import os.path
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from contextlib import contextmanager
|
||||
|
||||
|
@ -24,7 +23,6 @@ from taggit.managers import TaggableManager
|
|||
from unidecode import unidecode
|
||||
from willow.image import Image as WillowImage
|
||||
|
||||
from wagtail.utils.deprecation import RemovedInWagtail110Warning
|
||||
from wagtail.wagtailadmin.utils import get_object_usage
|
||||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import CollectionMember
|
||||
|
@ -356,16 +354,16 @@ def image_delete(sender, instance, **kwargs):
|
|||
instance.file.delete(False)
|
||||
|
||||
|
||||
# RemovedInWagtail110Warning: We will remove the models.Model
|
||||
class Filter(models.Model):
|
||||
class Filter(object):
|
||||
"""
|
||||
Represents one or more operations that can be applied to an Image to produce a rendition
|
||||
appropriate for final display on the website. Usually this would be a resize operation,
|
||||
but could potentially involve colour processing, etc.
|
||||
"""
|
||||
|
||||
# The spec pattern is operation1-var1-var2|operation2-var1
|
||||
spec = models.CharField(max_length=255, unique=True)
|
||||
def __init__(self, spec=None):
|
||||
# The spec pattern is operation1-var1-var2|operation2-var1
|
||||
self.spec = spec
|
||||
|
||||
@cached_property
|
||||
def operations(self):
|
||||
|
@ -457,28 +455,6 @@ class Filter(models.Model):
|
|||
|
||||
cls._registered_operations = dict(operations)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
warnings.warn(
|
||||
"Filter.save() is deprecated; Filter will no longer be an ORM model in Wagtail 1.10. "
|
||||
"Instantiate and use it in-memory instead",
|
||||
RemovedInWagtail110Warning, stacklevel=2
|
||||
)
|
||||
return super(Filter, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class WarnOnManagerAccess(object):
|
||||
def __get__(self, obj, objtype=None):
|
||||
warnings.warn(
|
||||
"Filter.objects is deprecated; Filter will no longer be an ORM model in Wagtail 1.10. "
|
||||
"Instantiate and use it in-memory instead",
|
||||
RemovedInWagtail110Warning, stacklevel=2
|
||||
)
|
||||
return objtype._objects
|
||||
|
||||
|
||||
Filter._objects = Filter.objects
|
||||
Filter.objects = WarnOnManagerAccess()
|
||||
|
||||
|
||||
class AbstractRendition(models.Model):
|
||||
filter_spec = models.CharField(max_length=255, db_index=True)
|
||||
|
|
Ładowanie…
Reference in New Issue