Browse Source

Ajst js de psq de autor e bug no queryset dinamico

pull/1356/head
LeandroRoberto 8 years ago
parent
commit
08c6f05aa0
  1. 13
      sapl/api/forms.py
  2. 10
      sapl/static/js/app.js

13
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

10
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;
}
}

Loading…
Cancel
Save