diff --git a/djadmin2/static/themes/bootstrap/js/actions.js b/djadmin2/static/themes/bootstrap/js/actions.js index 6b93d2f..64d25b9 100644 --- a/djadmin2/static/themes/bootstrap/js/actions.js +++ b/djadmin2/static/themes/bootstrap/js/actions.js @@ -2,7 +2,7 @@ $(function() { var element = $("#model-list"); var selectAllCheckbox = element.find('.model-select-all'); var selectCheckbox = element.find('.model-select'); - var selectedCount = element.find('#selected-count'); + var selectedCount = element.find('.selected-count'); var updateSelectedCount = function() { var count = 0; diff --git a/djadmin2/templates/djadmin2/bootstrap/includes/list_actions.html b/djadmin2/templates/djadmin2/bootstrap/includes/list_actions.html new file mode 100644 index 0000000..5b309d5 --- /dev/null +++ b/djadmin2/templates/djadmin2/bootstrap/includes/list_actions.html @@ -0,0 +1,24 @@ +{% load admin2_tags i18n %} + + diff --git a/djadmin2/templates/djadmin2/bootstrap/model_list.html b/djadmin2/templates/djadmin2/bootstrap/model_list.html index 75b857a..8309db6 100644 --- a/djadmin2/templates/djadmin2/bootstrap/model_list.html +++ b/djadmin2/templates/djadmin2/bootstrap/model_list.html @@ -42,29 +42,10 @@ {% csrf_token %}
- + {% if view.model_admin.actions_on_top %} + {% include 'djadmin2/bootstrap/includes/list_actions.html' with position='top' %} + {% endif %} @@ -110,7 +91,12 @@
- {{ object_list|length }} {{ model_name_pluralized }} + {% if view.model_admin.actions_on_bottom %} + {% include 'djadmin2/bootstrap/includes/list_actions.html' with position='bottom' %} + {% endif %} + +
{{ object_list|length }} {{ model_name_pluralized }}
+
diff --git a/example/blog/admin2.py b/example/blog/admin2.py index 47813e8..604b62a 100644 --- a/example/blog/admin2.py +++ b/example/blog/admin2.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import division, absolute_import, unicode_literals + from django.contrib import messages from django.utils.translation import ugettext_lazy @@ -37,6 +38,8 @@ class PostAdmin(djadmin2.ModelAdmin2): class CommentAdmin(djadmin2.ModelAdmin2): search_fields = ('body', '=post__title') list_filter = ['post', ] + actions_on_top = True + actions_on_bottom = True # Register each model with the admin diff --git a/example/blog/tests/test_views.py b/example/blog/tests/test_views.py index 6d87649..fae7fea 100644 --- a/example/blog/tests/test_views.py +++ b/example/blog/tests/test_views.py @@ -24,16 +24,18 @@ class AdminIndexTest(BaseIntegrationTest): response = self.client.get(reverse("admin2:dashboard")) self.assertContains(response, reverse("admin2:blog_post_index")) + class UserListTest(BaseIntegrationTest): def test_search_users_m2m_group(self): # This test should cause the distinct search path to exectue group = Group.objects.create(name="Test Group") self.user.groups.add(group) - params = {"q":"group"} + params = {"q": "group"} response = self.client.get(reverse("admin2:auth_user_index"), params) self.assertContains(response, 'user') + class CommentListTest(BaseIntegrationTest): def test_search_comments(self): # Test search across Foriegn Keys @@ -43,7 +45,7 @@ class CommentListTest(BaseIntegrationTest): Comment.objects.create(body="comment_post_1_b", post=post_1) Comment.objects.create(body="comment_post_2", post=post_2) - params = {"q":"post_1_title"} + params = {"q": "post_1_title"} response = self.client.get(reverse("admin2:blog_comment_index"), params) self.assertContains(response, "comment_post_1_a") self.assertContains(response, "comment_post_1_b") @@ -66,6 +68,12 @@ class PostListTest(BaseIntegrationTest): response = self.client.get(reverse("admin2:blog_post_index")) self.assertInHTML('Delete selected items', response.content) + def test_actions_displayed_twice(self): + # If actions_on_top and actions_on_bottom are both set + response = self.client.get(reverse("admin2:blog_comment_index")) + self.assertContains(response, '