Browse Source

Criando relatorio default

diagnosticos
Starlone (Estagiario) 15 years ago
parent
commit
2f0d88570e
  1. 135
      sigi/apps/convenios/reports.py
  2. 8
      sigi/settings.py

135
sigi/apps/convenios/reports.py

@ -1,53 +1,49 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
from ctypes import alignment
from operator import attrgetter from operator import attrgetter
from geraldo import Report, ReportBand, ObjectValue, DetailBand, Label, \ from geraldo import Report, ReportBand, ObjectValue, DetailBand, Label, \
landscape,SystemField, BAND_WIDTH,ReportGroup, \ landscape,SystemField, BAND_WIDTH,ReportGroup, \
FIELD_ACTION_SUM, FIELD_ACTION_COUNT FIELD_ACTION_SUM, FIELD_ACTION_COUNT
from geraldo.graphics import Image
from reportlab.lib.units import cm from reportlab.lib.units import cm
from reportlab.lib.pagesizes import A4 from reportlab.lib.pagesizes import A4
from reportlab.lib.enums import TA_CENTER, TA_RIGHT from reportlab.lib.enums import TA_CENTER, TA_RIGHT
class CasasAderidasReport(object): #from abc import ABCMeta
pass
class CasasNaoAderidasReport(object):
pass
class CasasComEquipamentosReport(object):
pass
class SemEquipamentosReport(object): class ReportDefault(Report):
pass #__metaclass__ = ABCMeta
class ConvenioReport(Report): title = u'Relatório'
title = u'Relatórios dos Convênios' author = u'Interlegis'
#author = u'Interlegis'
print_if_empty = True print_if_empty = True
page_size = A4#landscape(A4) page_size = A4
class band_page_header(ReportBand): class band_page_header(ReportBand):
height = 1.3*cm height = 4.2*cm
elements = [ elements = [
SystemField( Image(filename= 'apps/convenios/templates/imagens/logo-interlegis.jpg',
expression='%(report_title)s',top=0.1*cm,left=0,width=BAND_WIDTH, left=15.5*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
style={'fontName': 'Helvetica-Bold','fontSize':14, 'alignment': TA_CENTER} width=4.2*cm,height=3*cm,
), ),
SystemField(expression=u'Página %(page_number)d de %(page_count)d', top=0.1*cm, Image(filename= 'apps/convenios/templates/imagens/logo-senado.png',
width=BAND_WIDTH, style={'alignment': TA_RIGHT} left=1*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
), width=3*cm,height=3*cm,
Label(
text="Nº Processo", left=0.5*cm, top=0.8*cm
), ),
Label( Label(text="SENADO FEDERAL",top=1*cm,left=0,width=BAND_WIDTH,
text="Nome", left=3*cm, top=0.8*cm style={'fontName': 'Helvetica-Bold','fontSize':14, 'alignment': TA_CENTER}
), ),
Label( Label(text="SINTER - Secretaria Especial do Interlegis",top=1.5*cm,left=0,width=BAND_WIDTH,
text="Data Adesão", left=7*cm, top=0.8*cm style={'fontName': 'Helvetica-Bold','fontSize':13, 'alignment': TA_CENTER}
), ),
Label( SystemField(
text="Projeto", left=10*cm, top=0.8*cm expression='%(report_title)s',top=2.5*cm,left=0,width=BAND_WIDTH,
style={'fontName': 'Helvetica-Bold','fontSize':14, 'alignment': TA_CENTER}
), ),
] ]
borders = {'bottom': True} borders = {'bottom': True}
@ -56,35 +52,72 @@ class ConvenioReport(Report):
height = 0.5*cm height = 0.5*cm
elements = [ elements = [
Label(text='Interlegis', top=0.1*cm), SystemField(expression=u'%(now:%d/%m/%Y)s às %(now:%H:%M)s', top=0.1*cm),
SystemField(expression=u'Impresso em %(now:%d/%m/%Y)s às %(now:%H:%M)s', top=0.1*cm, SystemField(expression=u'Página %(page_number)d de %(page_count)d', top=0.1*cm,
width=BAND_WIDTH, style={'alignment': TA_RIGHT}), width=BAND_WIDTH, style={'alignment': TA_RIGHT}
),
] ]
borders = {'top': True} borders = {'top': True}
class band_detail(DetailBand): class band_detail(DetailBand):
height = 0.5*cm height = 0.5*cm
class CasasAderidasReport(object):
pass
class CasasNaoAderidasReport(object):
pass
class CasasComEquipamentosReport(object):
pass
class SemEquipamentosReport(object):
pass
class ConvenioReport(ReportDefault):
title = u'Relatório de Convênios'
class band_page_header(ReportDefault.band_page_header):
ReportDefault.band_page_header.elements += [
(Label(text="Estado", left=0.5*cm,top=3.7*cm)),
(Label(text="Nº Processo", left=3*cm,top=3.7*cm)),
(Label(text="Nome", left=6*cm,top=3.7*cm)),
(Label(text="Data Adesão", left=11*cm,top=3.7*cm)),
(Label(text="Projeto", left=14*cm,top=3.7*cm)),
]
class band_page_footer(ReportDefault.band_page_footer):
pass
class band_detail(ReportDefault.band_detail):
elements=[ elements=[
ObjectValue(attribute_name='num_processo_sf', left=0.5*cm), ObjectValue(attribute_name='casa_legislativa.municipio.uf', left=0.5*cm),
ObjectValue(attribute_name='casa_legislativa', left=3*cm), ObjectValue(attribute_name='num_processo_sf', left=3*cm),
ObjectValue(attribute_name='data_adesao', left=7*cm), ObjectValue(attribute_name='casa_legislativa', left=6*cm),
ObjectValue(attribute_name='projeto', left=10*cm) ObjectValue(attribute_name='data_adesao', left=11*cm,
get_value=lambda instance: instance.data_adesao.strftime('%d/%m/%Y')
),
ObjectValue(attribute_name='projeto', left=14*cm)
] ]
#border = {'bottom': True} #border = {'bottom': True}
groups = [ #groups = [
ReportGroup(attribute_name='casa_legislativa.municipio.uf', # ReportGroup(attribute_name='casa_legislativa.municipio.uf',
band_header=ReportBand( # band_header=ReportBand(
height=0.7*cm, # height=0.7*cm,
elements= [ # elements= [
ObjectValue(attribute_name='casa_legislativa.municipio.uf', # ObjectValue(attribute_name='casa_legislativa.municipio.uf',
get_Value= lambda instance: 'CasaLegislativa: '+ (instance.casa_legislativa.uf.regiao) # get_Value= lambda instance: 'CasaLegislativa: '+ (instance.casa_legislativa.uf.regiao)
) # )
], # ],
borders={'bottom': True}, # borders={'bottom': True},
) # )
) # )
] #]
class ConvenioReportRegiao(Report): class ConvenioReportRegiao(Report):
@ -124,10 +157,10 @@ class ConvenioReportRegiao(Report):
borders = {'top':True} borders = {'top':True}
child_bands = [ child_bands = [
ReportBand( ReportBand(
height = 0.6*cm, height = 0.6*cm,
elements = [ elements = [
Label(text="Total",), Label(text="Total",),
ObjectValue(attribute_name='casas', action=FIELD_ACTION_COUNT,) ObjectValue(attribute_name='casas', action=FIELD_ACTION_COUNT,)
] ]
), ),
] ]

8
sigi/settings.py

@ -23,8 +23,12 @@ DEFAULT_FROM_EMAIL = 'noreply@localhost'
INTERNAL_IPS = ('127.0.0.1',) INTERNAL_IPS = ('127.0.0.1',)
DATABASE_ENGINE = 'sqlite3' DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_NAME = BASE_DIR + '/devel.db' DATABASE_NAME = 'sigi'
DATABASE_USER = 'administrador'
DATABASE_PASSWORD = 'interlegis'
DATABASE_HOST = 'banco'
DATABASE_PORT = '5432'
TIME_ZONE = 'America/Sao_Paulo' TIME_ZONE = 'America/Sao_Paulo'
LANGUAGE_CODE = 'pt-br' LANGUAGE_CODE = 'pt-br'

Loading…
Cancel
Save