Browse Source

Ajustes nos módulos de parlamentares e mesas para atender demanda da comunicação - Requer ajuste no BD

stable/1.0
Sesostris Vieira 12 years ago
parent
commit
e8e6d0382a
  1. 30
      sigi/apps/casas/admin.py
  2. 24
      sigi/apps/mesas/admin.py
  3. 4
      sigi/apps/mesas/models.py
  4. 2
      sigi/apps/parlamentares/admin.py
  5. 1
      sigi/apps/parlamentares/models.py

30
sigi/apps/casas/admin.py

@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.contrib.contenttypes import generic
from django.http import HttpResponse, HttpResponseRedirect
from geraldo.generators import PDFGenerator
from sigi.apps.casas.forms import CasaLegislativaForm
from sigi.apps.casas.models import CasaLegislativa, Presidente, Funcionario
from sigi.apps.contatos.models import Telefone
from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo
from django.http import HttpResponse, HttpResponseRedirect
from sigi.apps.casas.reports import CasasLegislativasLabels, CasasLegislativasReport
from geraldo.generators import PDFGenerator
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.mesas.models import Legislatura
class TelefonesInline(generic.GenericTabularInline):
model = Telefone
@ -42,12 +43,31 @@ class ConveniosInline(admin.TabularInline):
exclude = ['equipada','conveniada','observacao']
extra = 1
class LegislaturaInline(admin.TabularInline):
model = Legislatura
fields = ['numero', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares', 'link_parlamentares',]
readonly_fields = ['link_parlamentares',]
def link_parlamentares(self, obj):
if obj.pk is None:
return ""
from django.core.urlresolvers import reverse
url = reverse('admin:%s_%s_change' %(obj._meta.app_label, obj._meta.module_name), args=[obj.pk] )
url = url + '?_popup=1'
return """<input id="edit_legislatura-%s" type="hidden"/>
<a id="lookup_edit_legislatura-%s" href="%s" class="changelink" onclick="return showRelatedObjectLookupPopup(this)">
Editar
</a>""" % (obj.pk, obj.pk, url)
link_parlamentares.short_description = 'Parlamentares'
link_parlamentares.allow_tags = True
class CasaLegislativaAdmin(admin.ModelAdmin):
form = CasaLegislativaForm
change_form_template = 'casas/change_form.html'
change_list_template = 'casas/change_list.html'
actions = ['adicionar_casas',]
inlines = (TelefonesInline, PresidenteInline, FuncionariosInline, ConveniosInline)
inlines = (TelefonesInline, PresidenteInline, FuncionariosInline, ConveniosInline, LegislaturaInline, )
list_display = ('nome','municipio','logradouro', 'ult_alt_endereco')
list_display_links = ('nome',)
list_filter = ('tipo', 'municipio')

24
sigi/apps/mesas/admin.py

@ -1,21 +1,41 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.http import HttpResponse
from django.utils.html import escape, escapejs
from sigi.apps.mesas.models import (Legislatura, Coligacao, ComposicaoColigacao,
SessaoLegislativa, MesaDiretora, Cargo,
MembroMesaDiretora)
from sigi.apps.parlamentares.models import Mandato
class MandatoInline(admin.TabularInline):
model = Mandato
raw_id_fields = ['parlamentar',]
class LegislaturaAdmin(admin.ModelAdmin):
date_hierarchy = 'data_inicio'
list_display = ('casa_legislativa', 'numero', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares')
list_display = ('numero', 'casa_legislativa', 'uf', 'data_inicio', 'data_fim', 'data_eleicao', 'total_parlamentares')
raw_id_fields = ('casa_legislativa',)
list_display_links = ('numero',)
list_filter = ('casa_legislativa', 'data_eleicao',)
list_filter = ('casa_legislativa', )
search_fields = ('numero', 'casa_legislativa')
inlines = (MandatoInline,)
def uf(self, obj):
return obj.casa_legislativa.municipio.uf.sigla
uf.short_description = 'UF'
uf.admin_order_field = 'casa_legislativa__municipio__uf'
def lookup_allowed(self, lookup, value):
return super(LegislaturaAdmin, self).lookup_allowed(lookup, value) or \
lookup in ['casa_legislativa__municipio__uf__codigo_ibge__exact']
def response_change(self, request, obj):
response = super(LegislaturaAdmin, self).response_change(request, obj)
if request.POST.has_key("_popup"):
response = HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
# escape() calls force_unicode.
(escape(obj.pk), escapejs(obj)))
return response
class ColigacaoAdmin(admin.ModelAdmin):
list_display = ('nome', 'legislatura', 'numero_votos')

4
sigi/apps/mesas/models.py

@ -15,10 +15,10 @@ class Legislatura(models.Model):
def meta(self):
unique_together = (('casa_legislativa', 'numero'))
ordering = ['-data_inicio']
ordering = ['casa_legislativa__municipio__uf__sigla', '-data_inicio']
def __unicode__(self):
return str(self.numero)
return "%sª legislatura da %s (%s-%s)" % (self.numero, self.casa_legislativa.__unicode__(), self.data_inicio.year, self.data_fim.year)
class Coligacao(models.Model):
nome = models.CharField(max_length=50)

2
sigi/apps/parlamentares/admin.py

@ -4,7 +4,7 @@ from django.contrib.contenttypes import generic
from sigi.apps.contatos.models import Telefone
from sigi.apps.parlamentares.models import Partido, Parlamentar, Mandato
class MandatosInline(admin.StackedInline):
class MandatosInline(admin.TabularInline):
model = Mandato
extra = 1
raw_id_fields = ('legislatura', 'partido')

1
sigi/apps/parlamentares/models.py

@ -74,6 +74,7 @@ class Mandato(models.Model):
parlamentar = models.ForeignKey(Parlamentar)
legislatura = models.ForeignKey('mesas.Legislatura')
partido = models.ForeignKey(Partido)
cargo = models.ForeignKey('mesas.Cargo')
inicio_mandato = models.DateField(u'início de mandato')
fim_mandato = models.DateField('fim de mandato')
is_afastado = models.BooleanField(

Loading…
Cancel
Save