Skip to content

Commit

Permalink
django 1.6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
un1t committed Jun 25, 2015
1 parent 6fb0e51 commit 9c4ed98
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Most django projects I've seen don't use transactions and this app is designed f
Features
========

- Support for Django 1.7, 1.8
- Support for Django 1.6, 1.7, 1.8
- Python 3 support
- Compatible with sorl-thumbnail and easy-thumbnail

Expand Down
8 changes: 6 additions & 2 deletions django_cleanup/models.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import django
from django.db import models
from django.apps import apps
try:
from django.apps import apps
get_models = apps.get_models
except (ImportError, AttributeError):
get_models = models.get_models
from django.db.models.signals import pre_save, post_delete

from .signals import cleanup_pre_delete, cleanup_post_delete


def find_models_with_filefield():
result = []
for model in apps.get_models():
for model in get_models():
for field in model._meta.fields:
if isinstance(field, models.FileField):
result.append(model)
Expand Down
1 change: 0 additions & 1 deletion django_cleanup/testapp/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
django>1.7,<1.8
sorl-thumbnail
easy-thumbnails
pillow
Expand Down
9 changes: 6 additions & 3 deletions django_cleanup/testapp/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ def test_remove_model_instance(pic1):


@pytest.mark.django_db
def test_remove_blank_file():
def test_remove_blank_file(monkeypatch):
def _raise(message):
raise Exception(message)

product = Product.objects.create(image='')
flexmock(product.image.storage).should_call('exists').times(0)
flexmock(product.image.storage).should_call('delete').times(0)
monkeypatch.setattr(product.image.storage, 'exists', lambda x: _raise('should not call exists'))
monkeypatch.setattr(product.image.storage, 'delete', lambda x: _raise('should not call delete'))
product.delete()


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

setup(
name = 'django-cleanup',
version = '0.3.0',
version = '0.3.1',
packages = ['django_cleanup'],
include_package_data=True,
requires = ['python (>= 2.5)', 'django (>= 1.3)'],
requires = ['python (>= 2.5)', 'django (>= 1.6)'],
description = 'Deletes old files.',
long_description = open('README.rst').read(),
author = 'Ilya Shalyapin',
Expand Down
9 changes: 7 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[tox]
envlist = py27,py34
envlist =
{py27,py34}-django{16,17,18}
[testenv]
deps = -rdjango_cleanup/testapp/requirements.txt
deps =
django18: django<1.9
django17: django<1.8
django16: django<1.7
-rdjango_cleanup/testapp/requirements.txt
commands=py.test -v --cov-report=term-missing --cov=django_cleanup django_cleanup

0 comments on commit 9c4ed98

Please sign in to comment.