Browse Source

Acrescentando geracao de etiquetas ao action de casas e alterando action de convenio

0.3
Starlone (Estagiario) 15 years ago
parent
commit
ff92f58b74
  1. 11
      sigi/apps/casas/admin.py
  2. 17
      sigi/apps/convenios/admin.py

11
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.casas.models import CasaLegislativa
from sigi.apps.contatos.models import Contato, Telefone from sigi.apps.contatos.models import Contato, Telefone
from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo 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): class ContatosInline(generic.GenericTabularInline):
model = Contato model = Contato
@ -23,6 +26,7 @@ class CasaLegislativaAdmin(admin.ModelAdmin):
form = CasaLegislativaForm form = CasaLegislativaForm
change_form_template = 'casas/change_form.html' change_form_template = 'casas/change_form.html'
change_list_template = 'casas/change_list.html' change_list_template = 'casas/change_list.html'
actions = ['delete_selected','etiqueta']
inlines = (TelefonesInline, ContatosInline, ConveniosInline) inlines = (TelefonesInline, ContatosInline, ConveniosInline)
list_display = ('nome', 'email', 'pagina_web', 'municipio') list_display = ('nome', 'email', 'pagina_web', 'municipio')
list_display_links = ('nome',) list_display_links = ('nome',)
@ -51,4 +55,11 @@ class CasaLegislativaAdmin(admin.ModelAdmin):
extra_context={'query_str': '?' + request.META['QUERY_STRING']} 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) admin.site.register(CasaLegislativa, CasaLegislativaAdmin)

17
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.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.servicos.models import Servico 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): class AnexosInline(admin.TabularInline):
model = Anexo model = Anexo
@ -53,10 +55,15 @@ class ConvenioAdmin(admin.ModelAdmin):
extra_context={'query_str': '?' + request.META['QUERY_STRING']} extra_context={'query_str': '?' + request.META['QUERY_STRING']}
) )
def relatorio(modeladmin, request, queryset): def relatorio(modeladmin, request, queryset):
selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME) response = HttpResponse(mimetype='application/pdf')
print selected report = ConvenioReport(queryset=queryset)
return HttpResponseRedirect("reports/?ids=%s"%(",".join(selected))) report.generate_by(PDFGenerator, filename=response)
relatorio.short_description = 'Selecione para gerar relatorio' 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): class EquipamentoPrevistoAdmin(admin.ModelAdmin):

Loading…
Cancel
Save