diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a6a4916..c6533a6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,18 @@ Changelog ========= +0.0.7-1 +----- +#. Fixes to support Django 1.5. + +0.0.7 +----- +#. Pass context to object_tools tag. Thanks `slafs `_ + +0.0.6 +----- +#. Corrected 'str' object has no attribute 'has_perm' bug `#7 `_. + 0.0.5-2 ------- #. Additional fixes to remove dependency on 'ADMIN_MEDIA_PREFIX' in Django 1.4. diff --git a/README.rst b/README.rst index a9a7921..f1b5f09 100644 --- a/README.rst +++ b/README.rst @@ -88,7 +88,7 @@ Now when you navigate to the change list view of any model you'll find the *dele .. image:: https://github.com/downloads/praekelt/django-object-tools/delete-example-final.png -Clicking on the *Delete all* tool fires of the view and proceeds with deleting objects as per usual. +Clicking on the *Delete all* tool fires off the view and proceeds with deleting objects as per usual. **Note:** ``django-object-tools`` adds per tool permissions to the built-in set of default Django permissions. So in this example only superusers or users who have the the *Can delete * permission will be able to see and use the tool. If you can't see or use a particular tool make sure the authenticated user has the required permissions to do so. diff --git a/object_tools/options.py b/object_tools/options.py index f870adb..a9effeb 100644 --- a/object_tools/options.py +++ b/object_tools/options.py @@ -24,6 +24,16 @@ def __init__(self, model): self.model = model self.modeladmin = site._registry.get(model) + if self.modeladmin: + self.modeladmin_changelist_view = self.modeladmin.changelist_view + self.modeladmin.changelist_view = self.changelist_view + + def changelist_view(self, request, extra_context=None): + """ + Simple wrapper to pass request to admin/change_list.html + """ + return self.modeladmin_changelist_view(request, extra_context={'request': request}) + def construct_form(self, request): """ Constructs form from POST method using self.form_class. @@ -52,8 +62,8 @@ def media(self, form): """ Collects admin and form media. """ - js = ['js/core.js', 'js/admin/RelatedObjectLookups.js', - 'js/jquery.min.js', 'js/jquery.init.js'] + js = ['admin/js/core.js', 'admin/js/admin/RelatedObjectLookups.js', + 'admin/js/jquery.min.js', 'admin/js/jquery.init.js'] admin_media_prefix = getattr(settings, 'ADMIN_MEDIA_PREFIX', '') or \ (getattr(settings, 'STATIC_URL', '') + 'admin/') diff --git a/object_tools/templates/admin/change_list.html b/object_tools/templates/admin/change_list.html index 31142d9..6bef586 100644 --- a/object_tools/templates/admin/change_list.html +++ b/object_tools/templates/admin/change_list.html @@ -59,7 +59,7 @@ {% if has_add_permission %}