From e57f821ce1f8ae16508306b2d5f9e81e8cbc9a39 Mon Sep 17 00:00:00 2001 From: bootandy Date: Sun, 7 Jul 2013 11:34:06 +0200 Subject: [PATCH] fix string filters --- djadmin2/static/themes/bootstrap/js/base.js | 13 +++++++++++++ djadmin2/templates/djadmin2/bootstrap/base.html | 1 + .../templates/djadmin2/bootstrap/model_list.html | 12 ++++++++---- example/blog/admin2.py | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 djadmin2/static/themes/bootstrap/js/base.js diff --git a/djadmin2/static/themes/bootstrap/js/base.js b/djadmin2/static/themes/bootstrap/js/base.js new file mode 100644 index 0000000..90a2857 --- /dev/null +++ b/djadmin2/static/themes/bootstrap/js/base.js @@ -0,0 +1,13 @@ +$(document).ready(function() { + + /** + * Dynamicaly adds button to each input element + * Required by filter section to allow form to be submitted + */ + $("#filter_form").find('input').each(function(){ + var input_field = $(this); + + var btn = input_field.after(''); + }); + +}); diff --git a/djadmin2/templates/djadmin2/bootstrap/base.html b/djadmin2/templates/djadmin2/bootstrap/base.html index f65acf4..7090ce5 100644 --- a/djadmin2/templates/djadmin2/bootstrap/base.html +++ b/djadmin2/templates/djadmin2/bootstrap/base.html @@ -78,6 +78,7 @@ + {% endblock javascript %} diff --git a/djadmin2/templates/djadmin2/bootstrap/model_list.html b/djadmin2/templates/djadmin2/bootstrap/model_list.html index 9c0b5e2..337e297 100644 --- a/djadmin2/templates/djadmin2/bootstrap/model_list.html +++ b/djadmin2/templates/djadmin2/bootstrap/model_list.html @@ -105,12 +105,16 @@ {% block filters %} - {% if list_filter %}
-

{% trans "Filter" %}

- {{ list_filter.form.as_p }} + {% if list_filter %} +

{% trans "Filter" %}

+
+ {{ list_filter.form.as_p }} +
+ {% else %} + Reset Filter + {% endif %}
- {% endif %} {% endblock filters %} diff --git a/example/blog/admin2.py b/example/blog/admin2.py index 63a40f1..72069ca 100644 --- a/example/blog/admin2.py +++ b/example/blog/admin2.py @@ -23,7 +23,7 @@ class PostAdmin(djadmin2.ModelAdmin2): list_actions = [DeleteSelectedAction, CustomPublishAction, unpublish_items] inlines = [CommentInline] search_fields = ('title', '^body') - list_filter = ['published', ] + list_filter = ['published', 'title'] class CommentAdmin(djadmin2.ModelAdmin2):