Skip to content

Commit

Permalink
some final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnyrose committed Feb 11, 2023
1 parent a13ae5e commit 31816fe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- python: "3.10"
toxenv: py310-django41
- python: "3.11"
toxenv: py310-django41
toxenv: py311-django41
- python: "pypy-3.8"
toxenv: pypy3-django41
steps:
Expand Down
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [7.0.0] - TBD
### Added
- Update to run tests for django 4.1.
- Update to run tests on python 3.11 with django 4.1.
- Select mode, with the ability to only cleanup selected models using a `select` decorator. Resolves issue [#75].
- Run tests for django 4.1.
- Run tests on python 3.11 with django 4.1.
- Select mode, with the ability to only cleanup selected models using a `select` decorator. Resolves issue [#75] for [@daviddavis](https://github.com/daviddavis).
- Documentation on the known limitations of referencing a file by multiple model instances. Resolves issue [#98] for [@Grosskopf](https://github.com/Grosskopf)

## Changed
- Pass more data to the cleanup_pre_delete and cleanup_post_delete signals. Resolves issue [#96].
- Pass more data to the cleanup_pre_delete and cleanup_post_delete signals. Resolves issue [#96] for [@NadavK](https://github.com/NadavK).

### Removed
- Dropped support for django 2.2 and python 3.5.
Expand Down Expand Up @@ -81,7 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.4] - 2012-08-16
## [0.1.0] - 2012-08-14

[Unreleased]: https://github.com/un1t/django-cleanup/compare/6.0.0...HEAD
[Unreleased]: https://github.com/un1t/django-cleanup/compare/7.0.0...HEAD
[7.0.0]: https://github.com/un1t/django-cleanup/compare/6.0.0...7.0.0
[6.0.0]: https://github.com/un1t/django-cleanup/compare/5.2.0...6.0.0
[5.2.0]: https://github.com/un1t/django-cleanup/compare/5.1.0...5.2.0
Expand Down Expand Up @@ -117,12 +118,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.1.4]: https://github.com/un1t/django-cleanup/compare/0.1.0...0.1.4
[0.1.0]: https://github.com/un1t/django-cleanup/releases/tag/0.1.0

[#98]: https://github.com/un1t/django-cleanup/issues/98
[#96]: https://github.com/un1t/django-cleanup/issues/96
[#89]: https://github.com/un1t/django-cleanup/issues/89
[#88]: https://github.com/un1t/django-cleanup/pull/88
[#86]: https://github.com/un1t/django-cleanup/pull/86
[#81]: https://github.com/un1t/django-cleanup/pull/81
[#80]: https://github.com/un1t/django-cleanup/pull/80
[#76]: https://github.com/un1t/django-cleanup/pull/76
[#75]: https://github.com/un1t/django-cleanup/issues/75
[#74]: https://github.com/un1t/django-cleanup/pull/74
[#73]: https://github.com/un1t/django-cleanup/issues/73
15 changes: 8 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ whether or not a :code:`FileField`'s value has changed a local cache of original
the model instance. If a condition is detected that should result in a file deletion, a function to
delete the file is setup and inserted into the commit phase of the current transaction.

**Warning! Please be aware of the Known Limitations documented below!**
**Warning! Please be aware of the known limitations documented below!**

Installation
============
Expand Down Expand Up @@ -71,10 +71,10 @@ You can check if your ``Model`` is loaded by using
from django.apps import apps
apps.get_models()
Known Limitations
Known limitations
=================

Database Should Support Transactions
Database should support transactions
------------------------------------
If you are using a database that does not support transactions you may lose files if a
transaction will rollback at the right instance. This outcome is mitigated by our use of
Expand All @@ -87,10 +87,11 @@ concerned about this behavior you will need another solution for old file deleti
File referenced by multiple model instances
-------------------------------------------
This app is designed with the assumption that each file is referenced only once. If you are sharing
a file over two or more model instances you will not have the desired functionality. If you want to
reference a file from multiple models add a level of indirection. That is, use a separate file model
that is referenced from other models through a foreign key. There are many file management apps
already available in the django ecosystem that fulfill this behavior.
a file over two or more model instances you will not have the desired functionality. Be cautious of
copying model instances, as this will cause a file to be shared by more than one instance. If you
want to reference a file from multiple models add a level of indirection. That is, use a separate
file model that is referenced from other models through a foreign key. There are many file
management apps already available in the django ecosystem that fulfill this behavior.

Advanced
========
Expand Down
2 changes: 1 addition & 1 deletion src/django_cleanup/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CleanupConfig(AppConfig):
default = True

def ready(self):
cache.prepare()
cache.prepare(False)
handlers.connect()

class CleanupSelectedConfig(AppConfig):
Expand Down
3 changes: 2 additions & 1 deletion src/django_cleanup/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def fields_dict_default():
# cache init ##


def prepare(select_mode=False):
def prepare(select_mode):
'''Prepare the cache for all models, non-reentrant'''
if FIELDS: # pragma: no cover
return
Expand Down Expand Up @@ -121,6 +121,7 @@ def get_mangled_select(model):
'''returns a mangled attribute name specific to the model for select functionality'''
return '_{opt.model_name}__{opt.app_label}_cleanup_select'.format(opt=model._meta)


# booleans ##


Expand Down

0 comments on commit 31816fe

Please sign in to comment.