From b48dfe8fb9d267be918dd0d272785ed581260509 Mon Sep 17 00:00:00 2001 From: PJ Passalacqua Date: Tue, 7 Jun 2016 16:24:31 -0400 Subject: [PATCH 1/3] Fixed select2 widgets not initializing --- advanced_filters/static/advanced-filters/advanced-filters.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/advanced_filters/static/advanced-filters/advanced-filters.js b/advanced_filters/static/advanced-filters/advanced-filters.js index 4dda293..e48fdbc 100644 --- a/advanced_filters/static/advanced-filters/advanced-filters.js +++ b/advanced_filters/static/advanced-filters/advanced-filters.js @@ -70,7 +70,11 @@ var OperatorHandlers = function($) { MODEL_LABEL) + '/' + field; var input = $(elm).parents('tr').find('input.query-value'); input.select2("destroy"); + var value = input.val(); $.get(choices_url, function(data) { + if (value) { + data.results.push({'id': value, 'text': value}) + } input.select2({'data': data, 'createSearchChoice': function(term) { return { 'id': term, 'text': term }; }}); @@ -127,6 +131,7 @@ var OperatorHandlers = function($) { $(this).data('pre_change', $(this).val()); }).change(); }); + self.initialize_select2(this) }; self.destroy = function() { From 0c639d6cbd07371d0f5298b7ac92563885467b38 Mon Sep 17 00:00:00 2001 From: PJ Passalacqua Date: Tue, 7 Jun 2016 16:46:15 -0400 Subject: [PATCH 2/3] fixed bad placement of initialize_select2 call --- advanced_filters/static/advanced-filters/advanced-filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced_filters/static/advanced-filters/advanced-filters.js b/advanced_filters/static/advanced-filters/advanced-filters.js index e48fdbc..efbb020 100644 --- a/advanced_filters/static/advanced-filters/advanced-filters.js +++ b/advanced_filters/static/advanced-filters/advanced-filters.js @@ -130,8 +130,8 @@ var OperatorHandlers = function($) { if ($(this).val() != before_change) self.field_selected(this); $(this).data('pre_change', $(this).val()); }).change(); + self.initialize_select2(this) }); - self.initialize_select2(this) }; self.destroy = function() { From f37013c9ad45dcb1813b82dbb59bed99fb79e976 Mon Sep 17 00:00:00 2001 From: Hermano Cabral Date: Tue, 12 Jul 2016 10:10:15 -0400 Subject: [PATCH 3/3] Changes URL declaration to avoid deprecated pattern This commit changes the way the URLs are declared to avoid RemovedInDjango110Warning messages. The old way, using django.conf.urls.patterns(), is deprecated and will be removed in Django 1.10 --- advanced_filters/urls.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/advanced_filters/urls.py b/advanced_filters/urls.py index fbd196a..a8fd76e 100644 --- a/advanced_filters/urls.py +++ b/advanced_filters/urls.py @@ -1,10 +1,8 @@ -from django.conf.urls import patterns, url +from django.conf.urls import url from advanced_filters.views import GetFieldChoices -urlpatterns = patterns( - # API - '', +urlpatterns = [ url(r'^field_choices/(?P.+)/(?P.+)/?', GetFieldChoices.as_view(), name='afilters_get_field_choices'), @@ -13,4 +11,4 @@ url(r'^field_choices/$', GetFieldChoices.as_view(), name='afilters_get_field_choices'), -) +]