diff --git a/.gitignore b/.gitignore index 2ed7bdc..ec91120 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -build/ -dist/ -*.egg-info/ \ No newline at end of file +*.pyc +*.egg-info +.tox diff --git a/README.markdown b/README.rst similarity index 81% rename from README.markdown rename to README.rst index 3841024..6bcfd11 100644 --- a/README.markdown +++ b/README.rst @@ -1,5 +1,3 @@ -# django-cleanup - django-cleanup automatically deletes old file for FileField, ImageField and subclasses, and it also deletes files on models instance deletion. @@ -8,19 +6,29 @@ If you are concerned about it you need other solution for old file deletion in y Most django projects I've seen don't use transactions and this app is designed for such projects. -## How does it work? +Features +======== + +- Support for Django 1.3, 1.4, 1.5, 1.6 and 1.7 +- Python 3 support + + +How does it work? +================= django-cleanup connects pre_save and post_delete signals to special functions(these functions delete old files) for each model which app is listed in INSTALLED_APPS above than 'django_cleanup'. -## Installation +Installation +============ pip install django-cleanup -## Configuration +Configuration +============= -Add django_cleanup to settings.py +Add django_cleanup to settings.py :: INSTALLED_APPS = ( ... @@ -30,14 +38,17 @@ Add django_cleanup to settings.py **django_cleanup** should be placed after all your apps. (At least after those apps which need to remove files.) -## Signals +Signals +======= django-cleanup sends the following signals which can be imported from `django_cleanup.signals`: - * `cleanup_pre_delete` just _before_ a file is deleted. Passes a `file` keyword argument. - * `cleanup_post_delete` just _after_ a file is deleted. Passes a `file` keyword argument. +- **cleanup_pre_delete** just before a file is deleted. Passes a `file` keyword argument. +- **cleanup_post_delete** just after a file is deleted. Passes a `file` keyword argument. -### Signals example for sorl.thumbnail +Signals example for sorl.thumbnail +---------------------------------- +:: from django_cleanup.signals import cleanup_pre_delete, cleanup_post_delete @@ -47,13 +58,14 @@ django-cleanup sends the following signals which can be imported from `django_cl cleanup_pre_delete.connect(sorl_delete) -## How to run tests +How to run tests +================ - pip install -r django_cleanup/testapp/requirements.txt - ./runtests.py + tox -## License +License +======= django-cleanup is free software under terms of the MIT License. diff --git a/django_cleanup/testapp/models.py b/django_cleanup/testapp/models.py index 93c17d4..223f6df 100644 --- a/django_cleanup/testapp/models.py +++ b/django_cleanup/testapp/models.py @@ -3,4 +3,4 @@ class Product(models.Model): - image = models.ImageField(upload_to='testapp', blank=True) + image = models.FileField(upload_to='testapp', blank=True) diff --git a/django_cleanup/testapp/requirements.txt b/django_cleanup/testapp/requirements.txt index 423a9bb..718cd37 100644 --- a/django_cleanup/testapp/requirements.txt +++ b/django_cleanup/testapp/requirements.txt @@ -1,2 +1,4 @@ -django +django>1.7,<1.8 +django-nose +pinocchio flexmock diff --git a/runtests.py b/runtests.py index 243cc91..4c1ed64 100755 --- a/runtests.py +++ b/runtests.py @@ -14,6 +14,13 @@ 'django_cleanup', ), MIDDLEWARE_CLASSES = [], + TEST_RUNNER = 'django_nose.NoseTestSuiteRunner', + NOSE_ARGS = [ + '--with-spec', + '--spec-color', + '--verbosity=2', + '--nocapture', + ], ) if __name__ == "__main__": diff --git a/setup.py b/setup.py index d7f87e5..3800527 100644 --- a/setup.py +++ b/setup.py @@ -12,12 +12,12 @@ setup( name = 'django-cleanup', - version = '0.1.12', + version = '0.1.13', packages = ['django_cleanup'], include_package_data=True, requires = ['python (>= 2.5)', 'django (>= 1.3)'], description = 'Deletes old files.', - long_description = open('README.markdown').read(), + long_description = open('README.rst').read(), author = 'Ilya Shalyapin', author_email = 'ishalyapin@gmail.com', url = 'https://github.com/un1t/django-cleanup', @@ -29,5 +29,9 @@ 'Framework :: Django', 'Intended Audience :: Developers', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', ], ) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..aa0f819 --- /dev/null +++ b/tox.ini @@ -0,0 +1,5 @@ +[tox] +envlist = py27,py34 +[testenv] +deps = -rdjango_cleanup/testapp/requirements.txt +commands=./runtests.py