From 08c6f05aa01efb68f5a94021c078a50a4485a3a8 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Wed, 2 Aug 2017 13:45:38 -0300 Subject: [PATCH] Ajst js de psq de autor e bug no queryset dinamico --- sapl/api/forms.py | 13 ++++++++----- sapl/static/js/app.js | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sapl/api/forms.py b/sapl/api/forms.py index 41e40eacf..e4951c1e3 100644 --- a/sapl/api/forms.py +++ b/sapl/api/forms.py @@ -38,17 +38,20 @@ class SaplGenericRelationSearchFilterSet(FilterSet): item.related_query_name(), field[0]) ) - if len(field) == 3 and field[2](qtext) is not None: - q_fs = q_fs | Q(**{'%s__%s%s' % ( - item.related_query_name(), - field[0], - field[1]): qtext if len(field) == 2 else field[2](qtext)}) + # if len(field) == 3 and field[2](qtext) is not + # None: + q_fs = q_fs | Q(**{'%s__%s%s' % ( + item.related_query_name(), + field[0], + field[1]): qtext if len(field) == 2 + else field[2](qtext)}) q = q & q_fs if q: queryset = queryset.filter(q).order_by(*order_by) + print(queryset.query) return queryset diff --git a/sapl/static/js/app.js b/sapl/static/js/app.js index 1afa1eec5..0d311fd48 100644 --- a/sapl/static/js/app.js +++ b/sapl/static/js/app.js @@ -90,11 +90,11 @@ function autorModal() { $("#pesquisar").click(function() { var name_in_query = $("#q").val() - var q_0 = "q_0=nome__icontains" - var q_1 = "q_1=" + name_in_query - query = q_0 + "&" + q_1 + //var q_0 = "q_0=nome__icontains" + //var q_1 = name_in_query + //query = q_1 - $.get("/api/autor?" + query, function(data, status) { + $.get("/api/autor?q=" + name_in_query, function(data, status) { $("#div-resultado").children().remove(); if (data.pagination.total_entries == 0) { $("#selecionar").attr("hidden", "hidden"); @@ -235,4 +235,4 @@ function getCookie(name) { } } return cookieValue; -} \ No newline at end of file +}