diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 7fa715f..f46e7b7 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -5,6 +5,9 @@ from sigi.apps.casas.forms import CasaLegislativaForm from sigi.apps.casas.models import CasaLegislativa from sigi.apps.contatos.models import Contato, Telefone from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo +from django.http import HttpResponse, HttpResponseRedirect +from sigi.apps.casas.reports import CasasLegislativasLabels +from geraldo.generators import PDFGenerator class ContatosInline(generic.GenericTabularInline): model = Contato @@ -23,6 +26,7 @@ class CasaLegislativaAdmin(admin.ModelAdmin): form = CasaLegislativaForm change_form_template = 'casas/change_form.html' change_list_template = 'casas/change_list.html' + actions = ['delete_selected','etiqueta'] inlines = (TelefonesInline, ContatosInline, ConveniosInline) list_display = ('nome', 'email', 'pagina_web', 'municipio') list_display_links = ('nome',) @@ -51,4 +55,11 @@ class CasaLegislativaAdmin(admin.ModelAdmin): extra_context={'query_str': '?' + request.META['QUERY_STRING']} ) + def etiqueta(modelAdmin,request,queryset): + response = HttpResponse(mimetype='application/pdf') + report = CasasLegislativasLabels(queryset=queryset) + report.generate_by(PDFGenerator, filename=response) + return response + etiqueta.short_description = "Gerar etiqueta(s) da(s) casa(s) selecionada(s)" + admin.site.register(CasaLegislativa, CasaLegislativaAdmin) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index f4aac23..1ded868 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -3,7 +3,9 @@ from django.contrib import admin from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo from sigi.apps.casas.models import CasaLegislativa from sigi.apps.servicos.models import Servico -from django.http import HttpResponseRedirect +from django.http import HttpResponse, HttpResponseRedirect +from sigi.apps.convenios.reports import ConvenioReport +from geraldo.generators import PDFGenerator class AnexosInline(admin.TabularInline): model = Anexo @@ -53,10 +55,15 @@ class ConvenioAdmin(admin.ModelAdmin): extra_context={'query_str': '?' + request.META['QUERY_STRING']} ) def relatorio(modeladmin, request, queryset): - selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME) - print selected - return HttpResponseRedirect("reports/?ids=%s"%(",".join(selected))) - relatorio.short_description = 'Selecione para gerar relatorio' + 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' class EquipamentoPrevistoAdmin(admin.ModelAdmin):