From 0f7b9d50250341925a42196d116707bf7cb0bb52 Mon Sep 17 00:00:00 2001 From: Breno Teixeira Date: Mon, 10 Mar 2014 14:08:52 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20da=20view=20'query=5Forden?= =?UTF-8?q?a'=20do=20carrinho?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi.db | Bin 272384 -> 273408 bytes sigi/apps/casas/views.py | 38 +++++++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/sigi.db b/sigi.db index 6e8bdf4d69b72dc4cecc4edef59de08a3dce12d3..57ec2a3c07450e7863ee71e896632d8b68804d8b 100644 GIT binary patch delta 536 zcmZp;Akc6_V1hKO0Rsag_e2GIMuUwBS=J)Px`qY{hNe~qW>&^#dX}c976z7^?^&w} z@GvodV*sgT{>}Vtv!K8WW(h_vE}#G>8yC}N22Q3v2Ig%{eatybe>d|4)G=wQF#9qZ z=Vc_D7N(md8W$Iv8Dtn3mF5?jr&N|_WhGW7r5Ks>0!>t%EGVEj`9_c`ScgfGQE`5H zRh4;hWl45oN@iJVWqGkliBU#&d3vsSZYDR#*y&!XEDFtT!Q0(}8TZ|h;ADEq!2FQ; z5c6W@7UooDH)eHa4yKn(r+}{9$TXeXm`TmVSl7q|<}GtQ14{!#V>4bkW=BRN149#C z1Guz_m65rgrMZc@nI(6-x-rvsbz|ncZ+KW3fWc(I=)|PMECzJ0!geV|mS;@Ub<|j1 z@qzrn%;>}bkp&d%!F6ze#-AXs6#ojS{*=}xLFZ>C47u)N^mWo~9*VqDL_ zG?Q^XQ1xO)jmC6duxdh~HN8QFWt|P&t-u(9d8IL(8*Boh&;y$w0XG53w?I$S0)18q E0NbmMy8r+H delta 245 zcmZp;A<%F^V1hKO8Uq6(*F*(-MzxIzS=J&(x`u`dh89+)##RRAdX`28M&_oQ?^&w} za4|CfW&o*W{=HdH;5{=xBPRTL zVrG0;_Eucqs$ evAmfsq0I7vqcNSG)we0uadJVh!t^XvmO}uH4mw-_ diff --git a/sigi/apps/casas/views.py b/sigi/apps/casas/views.py index 8ba3219..af960f3 100644 --- a/sigi/apps/casas/views.py +++ b/sigi/apps/casas/views.py @@ -18,14 +18,22 @@ from django.conf import settings import csv -def query_ordena(qs,o,ot): - list_display = ('nome','municipio','logradouro') - - aux = list_display[(int(o)-1)] - if ot =='asc': - qs = qs.order_by(aux) - else: - qs = qs.order_by("-"+aux) +# @param qs: queryset +# @param o: (int) number of order field +def query_ordena(qs, o): + from sigi.apps.casas.admin import CasaLegislativaAdmin + list_display = CasaLegislativaAdmin.list_display + order_fields = [] + + 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 def get_for_qs(get,qs): @@ -34,13 +42,13 @@ def get_for_qs(get,qs): """ kwargs = {} for k,v in get.iteritems(): - if not (k == 'page' or k == 'pop' or k == 'q'): - if not k == 'o': - if k == "ot": - qs = query_ordena(qs,get["o"],get["ot"]) - else: - kwargs[str(k)] = v - qs = qs.filter(**kwargs) + if str(k) not in ('page', 'pop', 'q', '_popup', 'o', 'ot'): + kwargs[str(k)] = v + + qs = qs.filter(**kwargs) + if 'o' in get: + qs = query_ordena(qs,get['o']) + return qs def carrinhoOrGet_for_qs(request):