From c45a544a1d39874a5a4fcd748fe2f4d8c4f8d48b Mon Sep 17 00:00:00 2001 From: Ludvig Wadenstein Date: Sun, 2 Jun 2013 20:17:04 +0200 Subject: [PATCH 1/4] List row links to update or read page based on permissions --- .../templates/admin2/bootstrap/model_list.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/djadmin2/templates/admin2/bootstrap/model_list.html b/djadmin2/templates/admin2/bootstrap/model_list.html index cc8f058..6cc3068 100644 --- a/djadmin2/templates/admin2/bootstrap/model_list.html +++ b/djadmin2/templates/admin2/bootstrap/model_list.html @@ -46,15 +46,14 @@ - {{ obj }} - {% if permissions.has_view_permission %} - {% trans "Detail" %} - {% endif %} {% if permissions.has_change_permission %} - {% trans "Edit" %} - {% endif %} - {% if permissions.has_delete_permission %} - {% trans "Delete" %} + {{ obj }} + {% else %} + {% if permissions.has_view_permission %} + {{ obj }} + {% else %} + {{ obj }} + {% endif %} {% endif %} From 574037acfe40ece29fa66e753aeb9dca423e950f Mon Sep 17 00:00:00 2001 From: Ludvig Wadenstein Date: Sun, 2 Jun 2013 20:18:47 +0200 Subject: [PATCH 2/4] Chackbox column has apropriate width --- djadmin2/templates/admin2/bootstrap/model_list.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djadmin2/templates/admin2/bootstrap/model_list.html b/djadmin2/templates/admin2/bootstrap/model_list.html index 6cc3068..d7b73ac 100644 --- a/djadmin2/templates/admin2/bootstrap/model_list.html +++ b/djadmin2/templates/admin2/bootstrap/model_list.html @@ -38,7 +38,7 @@ - + From a802dfe8ae5bb3b6ba03c4566d6a61520f2d12b1 Mon Sep 17 00:00:00 2001 From: Ludvig Wadenstein Date: Sun, 2 Jun 2013 20:58:27 +0200 Subject: [PATCH 3/4] Replaced actions select with button dropdown. --- .../static/themes/bootstrap/js/actions.js | 15 ++++++++++-- .../admin2/bootstrap/model_list.html | 24 ++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/djadmin2/static/themes/bootstrap/js/actions.js b/djadmin2/static/themes/bootstrap/js/actions.js index daf3f0b..9ee124f 100644 --- a/djadmin2/static/themes/bootstrap/js/actions.js +++ b/djadmin2/static/themes/bootstrap/js/actions.js @@ -9,8 +9,8 @@ $(function() { for (var ix = 0; ix < selectCheckboxen.length; ix++) { if ($(selectCheckboxen[ix]).prop('checked')) { count++; - }; - }; + } + } selectAllCheckbox.prop('checked', count == selectCheckboxen.length); selectedCount.text(count); }; @@ -23,4 +23,15 @@ $(function() { selectCheckboxen.click(function(e) { updateSelectedCount(); }); + + + var actionDropdownLink = element.find('.dropdown-menu a'); + actionDropdownLink.click(function (e) { + e.preventDefault(); + var form = $(this).closest('form'); + form.find('input[name="' + $(this).data('name') + '"]').val( + $(this).data('value')); + form.submit(); + }); + }); diff --git a/djadmin2/templates/admin2/bootstrap/model_list.html b/djadmin2/templates/admin2/bootstrap/model_list.html index d7b73ac..aa46b7d 100644 --- a/djadmin2/templates/admin2/bootstrap/model_list.html +++ b/djadmin2/templates/admin2/bootstrap/model_list.html @@ -19,16 +19,22 @@
+ {% csrf_token %}
{{ model_name }}
- + {% for obj in object_list %} From 9c296ccff58457acbdcf2d2f4b3201c3ddbe28c1 Mon Sep 17 00:00:00 2001 From: Ludvig Wadenstein Date: Sun, 2 Jun 2013 21:09:04 +0200 Subject: [PATCH 4/4] Updated tests --- example/blog/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/blog/tests/test_views.py b/example/blog/tests/test_views.py index 3e4faee..7ccdf20 100644 --- a/example/blog/tests/test_views.py +++ b/example/blog/tests/test_views.py @@ -32,7 +32,7 @@ class PostListTest(BaseIntegrationTest): def test_actions_displayed(self): response = self.client.get(reverse("admin2:blog_post_index")) - self.assertInHTML('', response.content) + self.assertInHTML('Delete selected items', response.content) def test_delete_selected_post(self): post = Post.objects.create(title="a_post_title", body="body")
{{ model_name }}{{ model_name|capfirst }}