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

Loading…
Cancel
Save