TrangPham / django-admin-confirm

AdminConfirmMixin is a mixin for ModelAdmin that adds confirmations to changes, additions and actions.
Other
129 stars 16 forks source link

fix(MR-16): Use cache for FileField and ImageField #17

Closed TrangPham closed 3 years ago

TrangPham commented 3 years ago

So this took a very long time to get to. Here's the previous history #16. This is related to #8

That worked nicely for ManyToManyField but not for the ImageField or FileField.

This MR tries caching (which works for FileField and ImageField, but not ManyToManyField).... thus a combined solution is used. Cache is used primarily, but for any m2m/generic relation fields data it looked up from request.POST (sent via hidden embedded form) and saved the related models.

Note: Had to bypass _save_related and save_m2m but calls the underlaying functions

Tests have been added for ManyToMany, File, and Image fields and caching

TrangPham commented 3 years ago

Previously in 0.2.3.dev6 relied mostly on the cache and handled m2m fields as a special case. Now in 0.2.3.dev7 relying mostly on the post data and using cache to treat files and images as special cases.

Also added handy dandy tests readme to outline all the mutations that should be covered in test cases.

🤞 That this works better because .dev6 introduced more issues than it fixed.

TrangPham commented 3 years ago

0.2.3.dev9 is on testpypi. See: https://github.com/TrangPham/django-admin-confirm/issues/8#issuecomment-785305831 For more details of differences between dev7 and dev9