diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 1ded868..629da6c 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -39,12 +39,13 @@ class ConvenioAdmin(admin.ModelAdmin): ) actions = ['delete_selected', 'relatorio'] inlines = (AnexosInline, EquipamentoPrevistoInline) - list_display = ('id', 'casa_legislativa', - 'num_processo_sf', 'data_adesao', 'projeto', - ) + list_display = ('num_convenio', 'casa_legislativa', + 'data_adesao','data_retorno_assinatura','data_termo_aceite', + 'projeto', + ) list_filter = ('projeto','casa_legislativa','conveniada', 'equipada') date_hierarchy = 'data_adesao' - ordering = ('-id',) + ordering = ('casa_legislativa__municipio__uf','-id',) raw_id_fields = ('casa_legislativa',) search_fields = ('id', 'casa_legislativa__nome', 'num_processo_sf') @@ -55,14 +56,12 @@ class ConvenioAdmin(admin.ModelAdmin): extra_context={'query_str': '?' + request.META['QUERY_STRING']} ) def relatorio(modeladmin, request, queryset): + #queryset.order_by('casa_legislativa__municipio__uf') response = HttpResponse(mimetype='application/pdf') report = ConvenioReport(queryset=queryset) report.generate_by(PDFGenerator, filename=response) return response - #selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME) - #print selected - #return HttpResponseRedirect("reports/?ids=%s"%(",".join(selected))) - #relatorio.short_description = 'Selecione para gerar relatorio' + relatorio.short_description = 'Gerar relatorio dos convenios selecionados' diff --git a/sigi/apps/convenios/views.py b/sigi/apps/convenios/views.py index 5bb0bbc..b9ebd88 100644 --- a/sigi/apps/convenios/views.py +++ b/sigi/apps/convenios/views.py @@ -6,7 +6,7 @@ from sigi.apps.casas.models import CasaLegislativa def report(request, id=None): - qs = Convenio.objects.all() + qs = Convenio.objects.all().order_by('casa_legislativa__municipio__uf','casa_legislativa') if id: qs = qs.filter(pk=id) elif request.GET: #Se tiver algum parametro de pesquisa @@ -22,9 +22,9 @@ def report(request, id=None): query = 'id IN ('+ kwargs['ids'].__str__()+')' qs = Convenio.objects.extra(where=[query]) if not qs: - return HttpResponseRedirect('../') + return HttpResponseRedirect('../') response = HttpResponse(mimetype='application/pdf') - report = ConvenioReport(queryset=qs.order_by('casa_legislativa')) + report = ConvenioReport(queryset=qs) report.generate_by(PDFGenerator, filename=response) return response