Browse Source

Criando aplicação relatorios

diagnosticos
Camilo Carlos (Estagiario) 15 years ago
parent
commit
511494f16b
  1. 1
      sigi/apps/convenios/models.py
  2. 61
      sigi/apps/convenios/reports.py
  3. 1
      sigi/apps/convenios/templates/convenios/change_list.html
  4. 0
      sigi/apps/relatorios/__init__.py
  5. 3
      sigi/apps/relatorios/models.py
  6. 62
      sigi/apps/relatorios/reports.py
  7. 23
      sigi/apps/relatorios/tests.py
  8. 1
      sigi/apps/relatorios/views.py
  9. 2
      sigi/settings.py

1
sigi/apps/convenios/models.py

@ -17,6 +17,7 @@ class Convenio(models.Model):
verbose_name='Casa Legislativa'
)
casa_legislativa.convenio_uf_filter = True
casa_legislativa.convenio_cl_tipo_filter = True
num_processo_sf = models.CharField(
'número do processo SF',
max_length=11,

61
sigi/apps/convenios/reports.py

@ -5,70 +5,15 @@ 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
#from abc import ABCMeta
class ReportDefault(Report):
#__metaclass__ = ABCMeta
title = u'Relatório'
author = u'Interlegis'
print_if_empty = True
page_size = A4
class band_page_header(ReportBand):
height = 4.2*cm
label_top = 3.7*cm
default_style = {'fontName': 'Helvetica', 'fontSize':9}
BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '../../../../')
#BASE_DIR = os.path.abspath(os.getcwd() + '../..')
elements = [
Image(filename= BASE_DIR + '/media/images/logo-interlegis.jpg',
left=15.5*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
width=4.2*cm,height=3*cm,
),
Image(filename= BASE_DIR + '/media/images/logo-senado.png',
left=1*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
width=3*cm,height=3*cm,
),
Label(text="SENADO FEDERAL",top=1*cm,left=0,width=BAND_WIDTH,
style={'fontName': 'Helvetica-Bold','fontSize':14, 'alignment': TA_CENTER}
),
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}
),
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}
class band_page_footer(ReportBand):
height = 0.5*cm
elements = [
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
default_style = {'fontName': 'Helvetica', 'fontSize': 8}
from sigi.apps.relatorios.reports import ReportDefault
#from abc import ABCMeta
class CasasAderidasReport(object):
pass
@ -243,4 +188,4 @@ class ConvenioReportRegiao(Report):
ObjectValue(attribute_name='casas', action=FIELD_ACTION_COUNT,)
]
),
]
]

1
sigi/apps/convenios/templates/convenios/change_list.html

@ -5,6 +5,7 @@
{% if has_add_permission %}
<ul class="object-tools">
<li><a href="reports/{{ query_str }}">Relatórios</a></li>
<li><a href="reportsRegiao/">Sumário Região</a></li>
<li>
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}

0
sigi/apps/relatorios/__init__.py

3
sigi/apps/relatorios/models.py

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

62
sigi/apps/relatorios/reports.py

@ -0,0 +1,62 @@
#-*- coding:utf-8 -*-
import os
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 ReportDefault(Report):
#__metaclass__ = ABCMeta
title = u'Relatório'
author = u'Interlegis'
print_if_empty = True
page_size = A4
class band_page_header(ReportBand):
height = 4.2*cm
label_top = 3.7*cm
default_style = {'fontName': 'Helvetica', 'fontSize':9}
BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '../../../../')
#BASE_DIR = os.path.abspath(os.getcwd() + '../..')
elements = [
Image(filename= BASE_DIR + '/media/images/logo-interlegis.jpg',
left=15.5*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
width=4.2*cm,height=3*cm,
),
Image(filename= BASE_DIR + '/media/images/logo-senado.png',
left=1*cm,right=1*cm,top=0.1*cm,bottom=1*cm,
width=3*cm,height=3*cm,
),
Label(text="SENADO FEDERAL",top=1*cm,left=0,width=BAND_WIDTH,
style={'fontName': 'Helvetica-Bold','fontSize':14, 'alignment': TA_CENTER}
),
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}
),
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}
class band_page_footer(ReportBand):
height = 0.5*cm
elements = [
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
default_style = {'fontName': 'Helvetica', 'fontSize': 8}

23
sigi/apps/relatorios/tests.py

@ -0,0 +1,23 @@
"""
This file demonstrates two different styles of tests (one doctest and one
unittest). These will both pass when you run "manage.py test".
Replace these with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.failUnlessEqual(1 + 1, 2)
__test__ = {"doctest": """
Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}

1
sigi/apps/relatorios/views.py

@ -0,0 +1 @@
# Create your views here.

2
sigi/settings.py

@ -24,6 +24,7 @@ DEFAULT_FROM_EMAIL = 'noreply@localhost'
INTERNAL_IPS = ('127.0.0.1',)
DATABASE_ENGINE = 'postgresql_psycopg2'
#DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = 'sigi'
DATABASE_USER = 'administrador'
DATABASE_PASSWORD = 'interlegis'
@ -98,6 +99,7 @@ INSTALLED_APPS = (
'sigi.apps.mesas',
'sigi.apps.parlamentares',
'sigi.apps.servicos',
'sigi.apps.relatorios',
)
try:

Loading…
Cancel
Save