Browse Source

Ordenando convenios por UF e trocando os atributos do change_list

diagnosticos
Starlone (Estagiario) 15 years ago
parent
commit
9513d8131a
  1. 15
      sigi/apps/convenios/admin.py
  2. 6
      sigi/apps/convenios/views.py

15
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'

6
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

Loading…
Cancel
Save