mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-17 13:50:24 +00:00
Compare commits
17 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
238573051e | ||
|
|
417e33ff5a | ||
|
|
9d450a78b8 | ||
|
|
bc12a319b3 | ||
|
|
85f0741594 | ||
|
|
3317273401 | ||
|
|
94cc8ed9e4 | ||
|
|
60f35b0af5 | ||
|
|
2c85d5aafe | ||
|
|
f3c5f7cb16 | ||
|
|
66db460c24 | ||
|
|
6f7de35f79 | ||
|
|
de991d4048 | ||
|
|
595f7b35ef | ||
|
|
fc221335b7 | ||
|
|
58e44975c7 | ||
|
|
115b596a8d |
17 changed files with 78 additions and 206 deletions
73
.travis.yml
73
.travis.yml
|
|
@ -1,62 +1,35 @@
|
|||
sudo: false
|
||||
|
||||
language: python
|
||||
|
||||
sudo: false
|
||||
python:
|
||||
- "3.8"
|
||||
- "3.7"
|
||||
- "3.6"
|
||||
- "3.5"
|
||||
env:
|
||||
- DJANGO="master"
|
||||
- DJANGO="30"
|
||||
- DJANGO="22"
|
||||
- DJANGO="21"
|
||||
- DJANGO="21"
|
||||
- DJANGO="20"
|
||||
- DJANGO="111"
|
||||
|
||||
install:
|
||||
- pip install tox
|
||||
|
||||
script:
|
||||
- tox
|
||||
- tox -e py$(python -c 'import sys;print("".join(map(str, sys.version_info[:2])))')-django${DJANGO}
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
fast_finish: true
|
||||
include:
|
||||
- env: TOXENV=py27-django14
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django15
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django16
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django17
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django18
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django19
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django110
|
||||
python: 2.7
|
||||
- env: TOXENV=py27-django111
|
||||
python: 2.7
|
||||
- env: TOXENV=py33-django15
|
||||
python: 3.3
|
||||
- env: TOXENV=py33-django16
|
||||
python: 3.3
|
||||
- env: TOXENV=py33-django17
|
||||
python: 3.3
|
||||
- env: TOXENV=py33-django18
|
||||
python: 3.3
|
||||
- env: TOXENV=py34-django16
|
||||
python: 3.4
|
||||
- env: TOXENV=py34-django17
|
||||
python: 3.4
|
||||
- env: TOXENV=py34-django18
|
||||
python: 3.4
|
||||
- env: TOXENV=py34-django19
|
||||
python: 3.4
|
||||
- env: TOXENV=py34-django110
|
||||
python: 3.4
|
||||
- env: TOXENV=py34-django111
|
||||
python: 3.4
|
||||
- env: TOXENV=py35-django18
|
||||
python: 3.5
|
||||
- env: TOXENV=py35-django19
|
||||
python: 3.5
|
||||
- env: TOXENV=py35-django110
|
||||
python: 3.5
|
||||
- env: TOXENV=py35-django111
|
||||
python: 3.5
|
||||
|
||||
allow_failures:
|
||||
- env: DJANGO="master"
|
||||
exclude:
|
||||
- python: "3.5"
|
||||
env: DJANGO="30"
|
||||
- python: "3.5"
|
||||
env: DJANGO="master"
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#imagekit"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ Installation
|
|||
Usage Overview
|
||||
==============
|
||||
|
||||
.. _specs:
|
||||
|
||||
Specs
|
||||
-----
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ for getting this information.
|
|||
@property
|
||||
def processors(self):
|
||||
model, field_name = get_field_info(self.source)
|
||||
return [ResizeToFill(model.thumbnail_width, model.thumbnail_height)]
|
||||
return [ResizeToFill(model.thumbnail_width, thumbnail.avatar_height)]
|
||||
|
||||
register.generator('myapp:profile:avatar_thumbnail', AvatarThumbnail)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Caching
|
|||
|
||||
|
||||
Default Backend Workflow
|
||||
================
|
||||
========================
|
||||
|
||||
|
||||
``ImageSpec``
|
||||
|
|
@ -29,6 +29,8 @@ objects, but they've got a little trick up their sleeve: they represent files
|
|||
that may not actually exist!
|
||||
|
||||
|
||||
.. _cache-file-strategy:
|
||||
|
||||
Cache File Strategy
|
||||
-------------------
|
||||
|
||||
|
|
@ -55,6 +57,8 @@ The default strategy only defines the first two of these, as follows:
|
|||
file.generate()
|
||||
|
||||
|
||||
.. _cache-file-backend:
|
||||
|
||||
Cache File Backend
|
||||
------------------
|
||||
|
||||
|
|
@ -185,6 +189,11 @@ Or, in Python:
|
|||
def on_source_saved(self, file):
|
||||
file.generate()
|
||||
|
||||
.. note::
|
||||
|
||||
If you use custom storage backend for some specs,
|
||||
(storage passed to the field different than configured one)
|
||||
it's required the storage to be pickleable
|
||||
|
||||
|
||||
__ https://pypi.python.org/pypi/django-celery
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ execfile(os.path.join(os.path.dirname(__file__), '..', 'imagekit',
|
|||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = re.match('\d+\.\d+', pkgmeta['__version__']).group()
|
||||
version = re.match(r'\d+\.\d+', pkgmeta['__version__']).group()
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = pkgmeta['__version__']
|
||||
|
||||
|
|
|
|||
|
|
@ -79,12 +79,9 @@ IK3 provides analogous settings for cache file backends and strategies:
|
|||
IMAGEKIT_DEFAULT_CACHEFILE_BACKEND = 'path.to.MyCacheFileBackend'
|
||||
IMAGEKIT_DEFAULT_CACHEFILE_STRATEGY = 'path.to.MyCacheFileStrategy'
|
||||
|
||||
See the documentation on `cache file backends`_ and `cache file strategies`_
|
||||
See the documentation on :ref:`cache file backends <cache-file-backend>` and :ref:`cache file strategies <cache-file-strategy>`
|
||||
for more details.
|
||||
|
||||
.. _`cache file backends`:
|
||||
.. _`cache file strategies`:
|
||||
|
||||
|
||||
Conditional model ``processors``
|
||||
--------------------------------
|
||||
|
|
@ -93,9 +90,7 @@ In IK2, an ``ImageSpecField`` could take a ``processors`` callable instead of
|
|||
an iterable, which allowed processing decisions to made based on other
|
||||
properties of the model. IK3 does away with this feature for consistency's sake
|
||||
(if one kwarg could be callable, why not all?), but provides a much more robust
|
||||
solution: the custom ``spec``. See the `advanced usage`_ documentation for more.
|
||||
|
||||
.. _`advanced usage`:
|
||||
solution: the custom ``spec``. See the :doc:`advanced usage <advanced_usage>` documentation for more.
|
||||
|
||||
|
||||
Conditonal ``cache_to`` file names
|
||||
|
|
@ -109,9 +104,7 @@ There is a way to achieve custom file names by overriding your spec's
|
|||
``cachefile_name``, but it is not recommended, as the spec's default
|
||||
behavior is to hash the combination of ``source``, ``processors``, ``format``,
|
||||
and other spec options to ensure that changes to the spec always result in
|
||||
unique file names. See the documentation on `specs`_ for more.
|
||||
|
||||
.. _`specs`:
|
||||
unique file names. See the documentation on :ref:`specs` for more.
|
||||
|
||||
|
||||
Processors have moved to PILKit
|
||||
|
|
|
|||
|
|
@ -144,8 +144,24 @@ class ImageCacheFile(BaseIKFile, ImageFile):
|
|||
# file is hidden link to "file" attribute
|
||||
state.pop('_file', None)
|
||||
|
||||
# remove storage from state as some non-FileSystemStorage can't be
|
||||
# pickled
|
||||
settings_storage = get_singleton(
|
||||
settings.IMAGEKIT_DEFAULT_FILE_STORAGE,
|
||||
'file storage backend'
|
||||
)
|
||||
if state['storage'] == settings_storage:
|
||||
state.pop('storage')
|
||||
return state
|
||||
|
||||
def __setstate__(self, state):
|
||||
if 'storage' not in state:
|
||||
state['storage'] = get_singleton(
|
||||
settings.IMAGEKIT_DEFAULT_FILE_STORAGE,
|
||||
'file storage backend'
|
||||
)
|
||||
self.__dict__.update(state)
|
||||
|
||||
def __nonzero__(self):
|
||||
# Python 2 compatibility
|
||||
return self.__bool__()
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class Simple(CachedFileBackend):
|
|||
|
||||
def _exists(self, file):
|
||||
return bool(getattr(file, '_file', None)
|
||||
or file.storage.exists(file.name))
|
||||
or (file.name and file.storage.exists(file.name)))
|
||||
|
||||
|
||||
def _generate_file(backend, file, force=False):
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class BaseIKFile(File):
|
|||
|
||||
def _get_size(self):
|
||||
self._require_file()
|
||||
if not self._committed:
|
||||
if not getattr(self, '_committed', False):
|
||||
return self.file.size
|
||||
return self.storage.size(self.name)
|
||||
size = property(_get_size)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import mock
|
||||
from unittest import mock
|
||||
from django.conf import settings
|
||||
from hashlib import md5
|
||||
from imagekit.cachefiles import ImageCacheFile, LazyImageCacheFile
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ def test_dangling_html_attrs_delimiter():
|
|||
@raises(TemplateSyntaxError)
|
||||
def test_html_attrs_assignment():
|
||||
"""
|
||||
You can either use generateimage as an assigment tag or specify html attrs,
|
||||
You can either use generateimage as an assignment tag or specify html attrs,
|
||||
but not both.
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from nose.tools import assert_false
|
||||
from mock import Mock, PropertyMock, patch
|
||||
from unittest.mock import Mock, PropertyMock, patch
|
||||
from .models import Photo
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from nose.tools import assert_true, assert_false
|
||||
from imagekit.cachefiles import ImageCacheFile
|
||||
from mock import Mock
|
||||
from unittest.mock import Mock
|
||||
from .utils import create_image
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from imagekit.cachefiles.backends import Simple as SimpleCFBackend
|
||||
|
|
|
|||
|
|
@ -37,4 +37,7 @@ def test_cachefiles():
|
|||
# remove link to file from spec source generator
|
||||
# test __getstate__ of ImageCacheFile
|
||||
file.generator.source = None
|
||||
pickleback(file)
|
||||
restored_file = pickleback(file)
|
||||
assert file is not restored_file
|
||||
# Assertion for #437 and #451
|
||||
assert file.storage is restored_file.storage
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def test_too_many_args():
|
|||
@raises(TemplateSyntaxError)
|
||||
def test_html_attrs_assignment():
|
||||
"""
|
||||
You can either use thumbnail as an assigment tag or specify html attrs,
|
||||
You can either use thumbnail as an assignment tag or specify html attrs,
|
||||
but not both.
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def render_tag(ttag):
|
|||
|
||||
|
||||
def get_html_attrs(ttag):
|
||||
return BeautifulSoup(render_tag(ttag)).img.attrs
|
||||
return BeautifulSoup(render_tag(ttag), features="html.parser").img.attrs
|
||||
|
||||
|
||||
def assert_file_is_falsy(file):
|
||||
|
|
|
|||
145
tox.ini
145
tox.ini
|
|
@ -1,141 +1,18 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py35-django111, py35-django110, py35-django19, py35-django18,
|
||||
py34-django111, py34-django110, py34-django19, py34-django18, py34-django17, py34-django16,
|
||||
py33-django18, py33-django17, py33-django16, py33-django15,
|
||||
py27-django111, py27-django110, py27-django19, py27-django18, py27-django17, py27-django16, py27-django15, py27-django14,
|
||||
py38-django{master,30,22,21,20,111},
|
||||
py37-django{master,30,22,21,20,111},
|
||||
py36-django{master,30,22,21,20,111},
|
||||
py35-django{21,20,111},
|
||||
|
||||
[testenv]
|
||||
commands = python setup.py test
|
||||
|
||||
[testenv:py35-django111]
|
||||
basepython = python3.5
|
||||
deps =
|
||||
Django>=1.11a1,<1.12
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py35-django110]
|
||||
basepython = python3.5
|
||||
deps =
|
||||
Django>=1.10,<1.11
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py35-django19]
|
||||
basepython = python3.5
|
||||
deps =
|
||||
Django>=1.9,<1.10
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py35-django18]
|
||||
basepython = python3.5
|
||||
deps =
|
||||
Django>=1.8,<1.9
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py34-django111]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.11a1,<1.12
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py34-django110]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.10,<1.11
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py34-django19]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.9,<1.10
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py34-django18]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.8,<1.9
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py34-django17]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.7,<1.8
|
||||
django-nose==1.4
|
||||
|
||||
[testenv:py34-django16]
|
||||
basepython = python3.4
|
||||
deps =
|
||||
Django>=1.6,<1.7
|
||||
django-nose<=1.4.2
|
||||
|
||||
[testenv:py33-django18]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
Django>=1.8,<1.9
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py33-django17]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
Django>=1.7,<1.8
|
||||
django-nose==1.4
|
||||
|
||||
[testenv:py33-django16]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
Django>=1.6,<1.7
|
||||
django-nose<=1.4.2
|
||||
|
||||
[testenv:py33-django15]
|
||||
basepython = python3.3
|
||||
deps =
|
||||
Django>=1.5,<1.6
|
||||
django-nose==1.4
|
||||
|
||||
[testenv:py27-django111]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.11a1,<1.12
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py27-django110]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.10,<1.11
|
||||
django-nose==1.4.4
|
||||
|
||||
[testenv:py27-django19]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.9,<1.10
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py27-django18]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.8,<1.9
|
||||
django-nose==1.4.2
|
||||
|
||||
[testenv:py27-django17]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.7,<1.8
|
||||
django-nose==1.4
|
||||
|
||||
[testenv:py27-django16]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.6,<1.7
|
||||
django-nose<=1.4.2
|
||||
|
||||
[testenv:py27-django15]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.5,<1.6
|
||||
django-nose==1.4
|
||||
|
||||
[testenv:py27-django14]
|
||||
basepython = python2.7
|
||||
deps =
|
||||
Django>=1.4,<1.5
|
||||
django-nose==1.4
|
||||
djangomaster: git+https://github.com/django/django.git@master#egg=Django
|
||||
django30: Django>=3.0,<3.1
|
||||
django22: Django>=2.2,<3.0
|
||||
django21: Django>=2.1,<2.2
|
||||
django20: Django>=2.0,<2.1
|
||||
django111: Django>=1.11,<2.0
|
||||
django{21,20,111}: django-nose==1.4.5
|
||||
|
|
|
|||
Loading…
Reference in a new issue