Browse Source

Correção da view 'query_ordena' do carrinho

stable/2.0
Breno Teixeira 11 years ago
parent
commit
0f7b9d5025
  1. BIN
      sigi.db
  2. 34
      sigi/apps/casas/views.py

BIN
sigi.db

Binary file not shown.

34
sigi/apps/casas/views.py

@ -18,14 +18,22 @@ from django.conf import settings
import csv import csv
def query_ordena(qs,o,ot): # @param qs: queryset
list_display = ('nome','municipio','logradouro') # @param o: (int) number of order field
def query_ordena(qs, o):
aux = list_display[(int(o)-1)] from sigi.apps.casas.admin import CasaLegislativaAdmin
if ot =='asc': list_display = CasaLegislativaAdmin.list_display
qs = qs.order_by(aux) order_fields = []
else:
qs = qs.order_by("-"+aux) for order_number in o.split('.'):
order_number = int(order_number)
order = ''
if order_number != abs(order_number):
order_number = abs(order_number)
order = '-'
order_fields.append(order + list_display[order_number - 1])
qs = qs.order_by(*order_fields)
return qs return qs
def get_for_qs(get,qs): def get_for_qs(get,qs):
@ -34,13 +42,13 @@ def get_for_qs(get,qs):
""" """
kwargs = {} kwargs = {}
for k,v in get.iteritems(): for k,v in get.iteritems():
if not (k == 'page' or k == 'pop' or k == 'q'): if str(k) not in ('page', 'pop', 'q', '_popup', 'o', 'ot'):
if not k == 'o':
if k == "ot":
qs = query_ordena(qs,get["o"],get["ot"])
else:
kwargs[str(k)] = v kwargs[str(k)] = v
qs = qs.filter(**kwargs) qs = qs.filter(**kwargs)
if 'o' in get:
qs = query_ordena(qs,get['o'])
return qs return qs
def carrinhoOrGet_for_qs(request): def carrinhoOrGet_for_qs(request):

Loading…
Cancel
Save