From 46dfa02f58a3a12580f043f0c2bcf9e2d78d068e Mon Sep 17 00:00:00 2001 From: Breno Teixeira Date: Mon, 5 May 2014 16:17:54 -0300 Subject: [PATCH] Adicionando o campo de gerente de contas --- sigi/apps/casas/admin.py | 27 +++++++++++++++++---------- sigi/apps/casas/models.py | 14 ++++++++------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index c493c4f..0e2c3d2 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -1,26 +1,23 @@ # -*- coding: utf-8 -*- from django.contrib import admin from django.contrib.contenttypes import generic -from django.http import HttpResponse, HttpResponseRedirect +from django.http import HttpResponseRedirect -from geraldo.generators import PDFGenerator from sigi.apps.casas.forms import CasaLegislativaForm from sigi.apps.casas.models import CasaLegislativa, Presidente, Funcionario, TipoCasaLegislativa -from sigi.apps.casas.reports import CasasLegislativasLabels, CasasLegislativasReport from sigi.apps.casas.views import report_complete, labels_report, export_csv, \ labels_report_sem_presidente, report, \ adicionar_casas_carrinho from sigi.apps.utils import queryset_ascii from sigi.apps.contatos.models import Telefone -from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo +from sigi.apps.convenios.models import Convenio from sigi.apps.mesas.models import Legislatura from sigi.apps.diagnosticos.models import Diagnostico from sigi.apps.inventario.models import Bem from sigi.apps.servicos.models import Servico from sigi.apps.metas.models import PlanoDiretor from sigi.apps.ocorrencias.models import Ocorrencia -from django.utils.translation import ugettext as _ class TelefonesInline(generic.GenericTabularInline): @@ -28,6 +25,7 @@ class TelefonesInline(generic.GenericTabularInline): readonly_fields = ('ult_alteracao',) extra = 1 + class PresidenteInline(admin.StackedInline): model = Presidente exclude = ['cargo','funcao'] @@ -36,6 +34,7 @@ class PresidenteInline(admin.StackedInline): max_num = 1 inlines = (TelefonesInline) + class FuncionariosInline(admin.StackedInline): model = Funcionario fieldsets = ((None, { @@ -47,6 +46,7 @@ class FuncionariosInline(admin.StackedInline): def queryset(self, request): return self.model.objects.exclude(cargo="Presidente") + class ConveniosInline(admin.StackedInline): model = Convenio fieldsets = ( @@ -87,7 +87,8 @@ class ConveniosInline(admin.StackedInline): link_convenio.short_description = 'Editar convenio' link_convenio.allow_tags = True - + + class LegislaturaInline(admin.TabularInline): model = Legislatura fields = ['numero', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares', 'link_parlamentares',] @@ -106,7 +107,8 @@ class LegislaturaInline(admin.TabularInline): link_parlamentares.short_description = 'Parlamentares' link_parlamentares.allow_tags = True - + + class DiagnosticoInline(admin.TabularInline): model = Diagnostico fields = ['data_visita_inicio', 'data_visita_fim', 'publicado', 'data_publicacao', 'responsavel', 'link_diagnostico',] @@ -128,9 +130,11 @@ class DiagnosticoInline(admin.TabularInline): link_diagnostico.short_description = 'Ver PDF' link_diagnostico.allow_tags = True + class BemInline(admin.TabularInline): model = Bem - + + class ServicoInline(admin.TabularInline): model = Servico fields = ['url', 'contato_tecnico', 'contato_administrativo', 'hospedagem_interlegis', 'data_ativacao', 'data_alteracao', 'data_desativacao'] @@ -139,9 +143,11 @@ class ServicoInline(admin.TabularInline): max_num = 0 can_delete = False + class PlanoDiretorInline(admin.TabularInline): model = PlanoDiretor + class OcorrenciaInline(admin.TabularInline): model = Ocorrencia fields = ('data_criacao', 'assunto', 'prioridade', 'status', 'data_modificacao', 'setor_responsavel',) @@ -149,7 +155,8 @@ class OcorrenciaInline(admin.TabularInline): extra = 0 max_num = 0 can_delete = False - + + class CasaLegislativaAdmin(admin.ModelAdmin): form = CasaLegislativaForm change_form_template = 'casas/change_form.html' @@ -164,7 +171,7 @@ class CasaLegislativaAdmin(admin.ModelAdmin): queyrset = queryset_ascii fieldsets = ( (None, { - 'fields': ('tipo', 'nome', 'cnpj', 'num_parlamentares') + 'fields': ('tipo', 'nome', 'cnpj', 'num_parlamentares', 'gerente_contas') }), ('Endereço', { 'fields': ('data_instalacao', 'logradouro', 'bairro', diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index f3d745c..1ef1111 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -from django.db import models -from django.contrib.contenttypes import generic -from sigi.apps.parlamentares.models import Parlamentar -from sigi.apps.utils import SearchField -from datetime import datetime import random from unicodedata import normalize -from sigi.apps.contatos.models import Municipio +from datetime import datetime +from django.db import models +from django.contrib.contenttypes import generic + +from sigi.apps.utils import SearchField +from sigi.apps.servidores.models import Servidor class TipoCasaLegislativa(models.Model): """ Modelo para representar o tipo da Casa Legislativa @@ -44,6 +44,8 @@ class CasaLegislativa(models.Model): codigo_interlegis = models.CharField('Código Interlegis', max_length=3, blank=True) # codigo_interlegis.ts_filter = True + gerente_contas = models.ForeignKey(Servidor, verbose_name="Gerente de contas") + # Informações de contato logradouro = models.CharField( max_length=100,