...
 
Commits (30)
......@@ -11,3 +11,5 @@ public/
radarlegislativo/static/
secrets/
venv/
env
......@@ -30,7 +30,7 @@ dev_init_db:
cd radarlegislativo && python manage.py loaddata main/fixtures/tags.json \
main/fixtures/projetos.json \
main/fixtures/tramitacoes.json \
agenda/fixtures/comissoes.json
parlamento/fixtures/comissoes.json
dev:
./scripts/run_dev.sh
......
......@@ -19,7 +19,6 @@ from django.contrib import admin
from markdownx.admin import MarkdownxModelAdmin
from .models import Comissao, Evento
from .models import Evento
admin.site.register(Comissao)
admin.site.register(Evento, MarkdownxModelAdmin)
[
{
"model": "agenda.comissao",
"pk": 1,
"fields": {
"origem": "CA",
"nome": "Comiss\u00e3o de Constitui\u00e7\u00e3o, Justi\u00e7a e cidadania",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 2,
"fields": {
"origem": "SE",
"nome": "Comiss\u00e3o de Ci\u00eancia, Tecnologia, Inova\u00e7\u00e3o, Comunica\u00e7\u00e3o e Inform\u00e1tica",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 3,
"fields": {
"origem": "CA",
"nome": "Comiss\u00e3o de Transpar\u00eancia, Governan\u00e7a, Fiscaliza\u00e7\u00e3o e Controle e Defesa do Consumidor",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 4,
"fields": {
"origem": "SE",
"nome": "Comiss\u00e3o de Assuntos Econ\u00f4micos",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 5,
"fields": {
"origem": "CA",
"nome": "Comiss\u00e3o Especial sobre o Banco Central Regular Moedas Virtuais",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 6,
"fields": {
"origem": "CA",
"nome": "Comiss\u00e3o Especial sobre o Tratamento e Prote\u00e7\u00e3o de Dados Pessoais",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 7,
"fields": {
"origem": "SE",
"nome": "Comiss\u00e3o de Rela\u00e7\u00f5es Exteriores e de Defesa Nacional",
"link": ""
}
},
{
"model": "agenda.comissao",
"pk": 8,
"fields": {
"origem": "CA",
"nome": "Comiss\u00e3o de Seguridade Social e Fam\u00edlia",
"link": ""
}
}
]
[
{
"model": "agenda.evento",
"pk": 2,
"pk": 181,
"fields": {
"data": "2017-09-08",
"data": "2018-07-14",
"link": "",
"descricao": "Audi\u00eancia p\u00fablica para discutir os impactos das moedas virtuais, em especial o Bitcoins, na economia brasileira. Foram convidados, entre outros, o presidente do Banco Central, Ilan Goldfajn; e o secret\u00e1rio da Receita Federal do Brasil, Jorge Rachid.",
"comissao": 5
"descricao": "PL 3.357/2015\r\n\r\nEmenta: Disp\u00f5e sobre o crime de invadir dispositivo inform\u00e1tico, sem a devida autoriza\u00e7\u00e3o, modificando conte\u00fado de s\u00edtio da internet.\r\n\r\nAutor: Vicentinho J\u00fanior - PSB/TO\r\nRelator: Thiago Peixoto - PSD/GO, com parecer pela constitucionalidade, juridicidade, t\u00e9cnica legislativa e, no m\u00e9rito, pela aprova\u00e7\u00e3o deste, do PL 4093/2015, do PL 5842/2016 e do PL 5200/2016, apensados, e do Substitutivo da Comiss\u00e3o de Ci\u00eancia e Tecnologia, Comunica\u00e7\u00e3o e Inform\u00e1tica, com subemenda substitutiva.",
"comissao": 3
}
},
{
"model": "agenda.evento",
"pk": 3,
"pk": 182,
"fields": {
"data": "2017-09-13",
"data": "2018-07-14",
"link": "",
"descricao": "Audi\u00eancia p\u00fablica para discutir a liberdade de express\u00e3o e prote\u00e7\u00e3o de dados pessoais. Foram convidados representantes da Associa\u00e7\u00e3o Brasileira de Emissoras de R\u00e1dio e Televis\u00e3o (Abert), do Centro de Tecnologia e Sociedade da Funda\u00e7\u00e3o Get\u00falio Vargas - CTS/FGV, do F\u00f3rum Nacional pela Democratiza\u00e7\u00e3o da Comunica\u00e7\u00e3o - FNDC e da Associa\u00e7\u00e3o Brasileira de R\u00e1dio e Televis\u00e3o (Abratel).",
"comissao": 6
}
},
{
"model": "agenda.evento",
"pk": 4,
"fields": {
"data": "2017-09-12",
"link": "",
"descricao": "Audi\u00eancia P\u00fablica para debater a situa\u00e7\u00e3o dos Projetos Estrat\u00e9gicos das For\u00e7as Armadas, os programas de coopera\u00e7\u00e3o internacional do Brasil na \u00e1rea da Defesa e os planos do Ex\u00e9rcito para o desenvolvimento tecnol\u00f3gico neste setor. O Comandante do Ex\u00e9rcito Brasileiro estar\u00e1 presente.",
"comissao": 7
}
},
{
"model": "agenda.evento",
"pk": 5,
"fields": {
"data": "2017-09-11",
"link": "",
"descricao": "Semin\u00e1rio sobre \u201cTecnologia e Sa\u00fade P\u00fablica: solu\u00e7\u00f5es vi\u00e1veis para os desafios brasileiros\u201d. Entre outros, estar\u00e3o presentes representantes da IBM e da Comiss\u00e3o de Ci\u00eancia e Tecnologia da C\u00e2mara dos Deputados.",
"comissao": 8
"descricao": "Audi\u00eancia p\u00fablica com o objetivo de instruir o Projeto de Lei da C\u00e2mara (PLC) n.\u00ba 79, de 2016, que altera as Leis n.\u00ba 9.472, de 16 de julho de 1997, para permitir a adapta\u00e7\u00e3o da modalidade de outorga de servi\u00e7o de telecomunica\u00e7\u00f5es de concess\u00e3o para autoriza\u00e7\u00e3o, e n.\u00ba 9.998, de 17 de agosto de 2000; e d\u00e1 outras provid\u00eancias.\r\n\r\nPauta\r\n\r\nConvidados\r\n\r\n* Andr\u00e9 M\u00fcller Borges - Secret\u00e1rio de Telecomunica\u00e7\u00f5es do Minist\u00e9rio da Ci\u00eancia, Tecnologia, Inova\u00e7\u00f5es e Comunica\u00e7\u00f5es - MCTIC\r\n\r\n* Juarez Quadros do Nascimento - Presidente do Conselho Diretor da Ag\u00eancia Nacional de Telecomunica\u00e7\u00f5es -ANATEL\r\n\r\n* Ivan Andr\u00e9 Pacheco Rogedo - Secret\u00e1rio da Secretaria de Fiscaliza\u00e7\u00e3o de Infraestrutura H\u00eddrica, de Comunica\u00e7\u00f5es e de Minera\u00e7\u00e3o do Tribunal de Contas da Uni\u00e3o - SeinfraCOM/TCU\r\n\r\n* Marcos Urup\u00e1 - Coordenador do Intervozes - Coletivo Brasil de Comunica\u00e7\u00e3o Social\r\n\r\n* Fl\u00e1via Lef\u00e8vre Guimar\u00e3es - Conselheira da Associa\u00e7\u00e3o Brasileira de Defesa do Consumidor - PROTESTE\r\n\r\n* Carlos Duprat - Diretor-Executivo do Sindicato Nacional das Empresas de Telefonia e de Servi\u00e7o M\u00f3vel Celular e Pessoal - SindiTelebrasil\r\n\r\n* Paulo Tonet Camargo - Presidente da Associa\u00e7\u00e3o Brasileira de Emissoras de R\u00e1dio e de Televis\u00e3o - ABERT\r\n\r\n* Luiz Ot\u00e1vio Vasconcelos Prates - Diretor-Presidente do Sindicato Nacional de Empresas de Telecomunica\u00e7\u00f5es por Sat\u00e9lite - SINDISAT\r\n\r\n* Igor Rodrigues Britto - Advogado do Instituto Brasileiro de Defesa do Consumidor - IDEC\r\n\r\n* Marcio Patusco Lana Lobo - Diretor de Atividades T\u00e9cnicas do Clube de Engenharia\r\n\r\n* Jo\u00e3o de Moura Neto - Presidente da Federa\u00e7\u00e3o Interestadual dos Trabalhadores e Pesquisadores em Servi\u00e7os de Telecomunica\u00e7\u00f5es - FITRATELP",
"comissao": 2
}
}
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-23 15:33
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('agenda', '0005_auto_20180502_1841'),
('parlamento', '0002_comissao_comissaocamara_comissaosenado'),
]
operations = [
migrations.AlterField(
model_name='evento',
name='comissao',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='parlamento.Comissao'),
),
migrations.DeleteModel(
name='Comissao',
),
]
......@@ -22,20 +22,7 @@ from django.utils.encoding import python_2_unicode_compatible
from markdownx.models import MarkdownxField
from main.models import Projeto
@python_2_unicode_compatible
class Comissao(models.Model):
origem = models.CharField(max_length=2, choices=Projeto.ORIGEM_CHOICES)
nome = models.CharField(max_length=255)
link = models.URLField(blank=True)
class Meta:
verbose_name = "comissão"
verbose_name_plural = "comissões"
def __str__(self):
return u"{} - {}".format(self.nome, self.get_origem_display())
from parlamento.models import Comissao
class EventoManager(models.Manager):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from .models import (
ComissaoCamara,
ComissaoSenado,
Deputado,
Partido,
Senador,
)
admin.site.register(ComissaoCamara)
admin.site.register(ComissaoSenado)
admin.site.register(Deputado)
admin.site.register(Partido)
admin.site.register(Senador)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class ParlamentoConfig(AppConfig):
name = 'parlamento'
[
{
"model": "parlamento.comissao",
"pk": 2,
"fields": {
"id_api": 34,
"nome": "Comiss\u00e3o de Constitui\u00e7\u00e3o, Justi\u00e7a e Cidadania",
"sigla": "CCJ",
"link": "http://legis.senado.leg.br/comissoes/comissao;jsessionid=E1D1FCDB9D9393B436C4D9A29619BA20?0&codcol=34",
"tipo": "Comiss\u00e3o Permanente"
}
},
{
"model": "parlamento.comissao",
"pk": 3,
"fields": {
"id_api": 2003,
"nome": "Comiss\u00e3o de Constitui\u00e7\u00e3o e Justi\u00e7a e de Cidadania",
"sigla": "CCJC",
"link": "http://www2.camara.leg.br/atividade-legislativa/comissoes/comissoes-permanentes/ccjc",
"tipo": "Comiss\u00e3o Permanente"
}
}
]
# -*- coding: utf-8 -*-
# This file is part of Radar Legislativo
# Copyright © 2016 codingrights
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from django.core.management.base import BaseCommand
from tapioca_camara import Camara
from parlamento.models import ComissaoCamara
logger = logging.getLogger(__name__)
class Command(BaseCommand):
help = u"Popula banco com todas as comissões do Camara"
def add_arguments(self, parser):
parser.add_argument("--tipos", dest="tipos", default=[1, 2, 3, 4])
def handle(self, *args, **options):
camara = Camara()
logger.info('Importando comissões do Câmara')
paginacao = {'itens': 100, 'pagina': 1, 'idTipoOrgao': options['tipos']}
resposta = camara.orgaos().get(params=paginacao)
proxima_pagina = True
while proxima_pagina:
for comissao in resposta.dados:
ComissaoCamara.objects.create(
id_api=comissao.id._data,
nome=comissao.nome._data,
sigla=comissao.sigla._data,
tipo=comissao.tipoOrgao._data,
)
paginacao['pagina'] += 1
resposta = camara.orgaos().get(params=paginacao)
proxima_pagina = any(l for l in resposta.links if l.rel._data == 'next')
# -*- coding: utf-8 -*-
# This file is part of Radar Legislativo
# Copyright © 2016 codingrights
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
from django.core.management.base import BaseCommand
from tapioca_senado import Senado
from parlamento.models import ComissaoSenado
logger = logging.getLogger(__name__)
class Command(BaseCommand):
help = u"Popula banco com todas as comissões do Senado"
def handle(self, *args, **options):
senado = Senado()
logger.info('Importando comissões do Senado')
resposta = senado.comissoes().get()
for comissao in resposta.ListaColegiados.Colegiados.Colegiado:
ComissaoSenado.objects.create(
nome=comissao.Nome._data,
sigla=comissao.Sigla._data,
id_api=comissao.Codigo._data,
tipo=comissao.DescricaoTipoColegiado._data,
)
# -*- coding: utf-8 -*-
# This file is part of Radar Legislativo
# Copyright © 2016 codingrights
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.base import BaseCommand
from tapioca_camara import Camara
from parlamento.models import Deputado
class Command(BaseCommand):
help = u"Popula banco com todos os deputados em exercício atualmente"
def handle(self, *args, **options):
camara = Camara()
deputados_ids = []
paginacao = {'itens': 100, 'pagina': 1}
resposta = camara.deputados().get(params=paginacao)
proxima_pagina = True
while proxima_pagina:
for deputado in resposta.dados:
deputados_ids.append(deputado.id._data)
paginacao['pagina'] += 1
resposta = camara.deputados().get(params=paginacao)
proxima_pagina = any(l for l in resposta.links if l.rel._data == 'next')
deputados = []
for dep_id in deputados_ids:
deputado = camara.deputado(id=dep_id).get()
dados = deputado.dados._data
status = deputado.dados.ultimoStatus._data
deputados.append(Deputado(
id_api=dados['id'],
nome=dados['nomeCivil'],
nome_parlamentar=status['nome'],
foto=status['urlFoto'],
email=status['gabinete'].get('email'),
partido_id=status['siglaPartido'],
estado_id=status['siglaUf'],
participacao=status['condicaoEleitoral'],
))
Deputado.objects.bulk_create(deputados)
# -*- coding: utf-8 -*-
from django.core.management import BaseCommand
from parlamento.models import Estado
class Command(BaseCommand):
def handle(self, *args, **options):
UNIDADES_FEDERATIVAS = (
('Acre', 'AC'),
('Alagoas', 'AL'),
('Amapá', 'AP'),
('Amazonas', 'AM'),
('Bahia', 'BA'),
('Ceará', 'CE'),
('Distrito Federal', 'DF'),
('Espírito Santo', 'ES'),
('Goiás', 'GO'),
('Maranhão', 'MA'),
('Mato Grosso', 'MT'),
('Mato Grosso do Sul', 'MS'),
('Minas Gerais', 'MG'),
('Paraná', 'PR'),
('Paraíba', 'PB'),
('Pará', 'PA'),
('Pernambuco', 'PE'),
('Piauí', 'PI'),
('Rio Grande do Norte', 'RN'),
('Rio Grande do Sul', 'RS'),
('Rio de Janeiro', 'RJ'),
('Rondônia', 'RO'),
('Roraima', 'RR'),
('Santa Catarina', 'SC'),
('Sergipe', 'SE'),
('São Paulo', 'SP'),
('Tocantins', 'TO'),
)
for unidade in UNIDADES_FEDERATIVAS:
Estado.objects.create(sigla=unidade[1], nome=unidade[0])
import requests
from django.core.management import BaseCommand
from parlamento.models import Partido
class Command(BaseCommand):
def handle(self, *args, **options):
partidos = []
camara_url = 'https://dadosabertos.camara.leg.br/api/v2/partidos/?formato=json&itens=100'
resposta = requests.get(camara_url).json()
for partido in resposta['dados']:
partidos.append(Partido(
nome=partido['nome'],
sigla=partido['sigla'],
))
Partido.objects.bulk_create(partidos)
# -*- coding: utf-8 -*-
# This file is part of Radar Legislativo
# Copyright © 2016 codingrights
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.base import BaseCommand
from tapioca_senado import Senado
from parlamento.models import Senador
class Command(BaseCommand):
help = u"Popula banco com todos os senadores em exercício atualmente"
def handle(self, *args, **options):
senadores = []
senado = Senado()
resposta = senado.senadores().get()
for senador in resposta.ListaParlamentarEmExercicio.Parlamentares.Parlamentar:
data = senador.IdentificacaoParlamentar._data
senadores.append(Senador(
id_api=data['CodigoParlamentar'],
nome=data['NomeCompletoParlamentar'],
nome_parlamentar=data['NomeParlamentar'],
foto=data['UrlFotoParlamentar'],
pagina_oficial=data['UrlPaginaParlamentar'],
email=data.get('EmailParlamentar'),
partido_id=data['SiglaPartidoParlamentar'],
estado_id=data['UfParlamentar'],
participacao=data.get('DescricaoParticipacao'),
))
Senador.objects.bulk_create(senadores)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-18 03:01
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Deputado',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=255, verbose_name='Nome Completo')),
('nome_parlamentar', models.CharField(max_length=255, verbose_name='Nome Parlamentar')),
('participacao', models.CharField(blank=True, max_length=20, null=True, verbose_name='Participa\xe7\xe3o')),
('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='E-mail')),
('pagina_oficial', models.URLField(verbose_name='P\xe1gina Oficial')),
('foto', models.URLField(verbose_name='Foto')),
('facebook', models.URLField(blank=True, null=True, verbose_name='Facebook')),
('twitter', models.URLField(blank=True, null=True, verbose_name='Twitter')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='Estado',
fields=[
('sigla', models.CharField(max_length=2, primary_key=True, serialize=False, verbose_name='Sigla')),
('nome', models.CharField(max_length=100, verbose_name='Nome')),
],
),
migrations.CreateModel(
name='Partido',
fields=[
('sigla', models.CharField(max_length=2, primary_key=True, serialize=False, verbose_name='Sigla')),
('nome', models.CharField(max_length=100, verbose_name='Nome')),
],
),
migrations.CreateModel(
name='Senador',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.CharField(max_length=255, verbose_name='Nome Completo')),
('nome_parlamentar', models.CharField(max_length=255, verbose_name='Nome Parlamentar')),
('participacao', models.CharField(blank=True, max_length=20, null=True, verbose_name='Participa\xe7\xe3o')),
('email', models.EmailField(blank=True, max_length=254, null=True, verbose_name='E-mail')),
('pagina_oficial', models.URLField(verbose_name='P\xe1gina Oficial')),
('foto', models.URLField(verbose_name='Foto')),
('facebook', models.URLField(blank=True, null=True, verbose_name='Facebook')),
('twitter', models.URLField(blank=True, null=True, verbose_name='Twitter')),
('estado', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='senador', to='parlamento.Estado', verbose_name='Estado')),
('partido', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='senador', to='parlamento.Partido', verbose_name='Partido')),
],
options={
'abstract': False,
},
),
migrations.AddField(
model_name='deputado',
name='estado',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='deputado', to='parlamento.Estado', verbose_name='Estado'),
),
migrations.AddField(
model_name='deputado',
name='partido',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='deputado', to='parlamento.Partido', verbose_name='Partido'),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-23 15:33
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('parlamento', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Comissao',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_api', models.IntegerField(verbose_name='ID na API da casa')),
('nome', models.CharField(max_length=255, verbose_name='Nome')),
('sigla', models.CharField(max_length=255, verbose_name='Sigla')),
('link', models.URLField(blank=True)),
],
options={
'verbose_name': 'Comiss\xe3o',
'verbose_name_plural': 'Comiss\xf5es',
},
),
migrations.CreateModel(
name='ComissaoCamara',
fields=[
('comissao_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='parlamento.Comissao')),
],
bases=('parlamento.comissao',),
),
migrations.CreateModel(
name='ComissaoSenado',
fields=[
('comissao_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='parlamento.Comissao')),
],
bases=('parlamento.comissao',),
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-06-23 16:29
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parlamento', '0002_comissao_comissaocamara_comissaosenado'),
]
operations = [
migrations.AddField(
model_name='comissaocamara',
name='tipo',
field=models.CharField(default='Comiss\xe3o Permanente', max_length=100, verbose_name='Tipo'),
preserve_default=False,
),
migrations.AddField(
model_name='comissaosenado',
name='tipo',
field=models.CharField(choices=[('Permanente', 'Permanente'), ('CPI', 'CPI'), ('Tempor\xe1ria', 'Tempor\xe1ria')], default='Permanente', max_length=20, verbose_name='Tipo'),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-03 13:07
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parlamento', '0003_auto_20180623_1629'),
]
operations = [
migrations.AddField(
model_name='deputado',
name='id_api',
field=models.IntegerField(default=1, verbose_name='ID na API'),
preserve_default=False,
),
migrations.AddField(
model_name='senador',
name='id_api',
field=models.IntegerField(default=1, verbose_name='ID na API'),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-05 02:35
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('parlamento', '0004_auto_20180703_1307'),
]
operations = [
migrations.AlterModelOptions(
name='comissaocamara',
options={'verbose_name': 'Comiss\xe3o da C\xe2mara', 'verbose_name_plural': 'Comiss\xf5es da C\xe2mara'},
),
migrations.AlterModelOptions(
name='comissaosenado',
options={'verbose_name': 'Comiss\xe3o do Senado', 'verbose_name_plural': 'Comiss\xf5es do Senado'},
),
migrations.AlterModelOptions(
name='deputado',
options={'verbose_name': 'Deputado', 'verbose_name_plural': 'Deputados'},
),
migrations.AlterModelOptions(
name='senador',
options={'verbose_name': 'Senador', 'verbose_name_plural': 'Senadores'},
),
migrations.RemoveField(
model_name='comissaocamara',
name='tipo',
),
migrations.RemoveField(
model_name='comissaosenado',
name='tipo',
),
migrations.AddField(
model_name='comissao',
name='tipo',
field=models.CharField(default=1, max_length=255, verbose_name='Tipo'),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Estado(models.Model):
sigla = models.CharField('Sigla', max_length=2, primary_key=True)
nome = models.CharField('Nome', max_length=100)
def __str__(self):
return self.nome
@python_2_unicode_compatible
class Partido(models.Model):
sigla = models.CharField('Sigla', max_length=2, primary_key=True)
nome = models.CharField('Nome', max_length=100)
def __str__(self):
return self.nome
@python_2_unicode_compatible
class Parlamentar(models.Model):
id_api = models.IntegerField('ID na API')
nome = models.CharField('Nome Completo', max_length=255)
nome_parlamentar = models.CharField('Nome Parlamentar', max_length=255)
partido = models.ForeignKey(
Partido,
verbose_name='Partido',
related_name='%(class)s',
on_delete=models.PROTECT
)
estado = models.ForeignKey(
Estado,
verbose_name='Estado',
related_name='%(class)s',
on_delete=models.PROTECT
)
participacao = models.CharField('Participação', max_length=20, null=True, blank=True)
email = models.EmailField('E-mail', null=True, blank=True)
pagina_oficial = models.URLField('Página Oficial')
foto = models.URLField('Foto')
facebook = models.URLField('Facebook', null=True, blank=True)
twitter = models.URLField('Twitter', null=True, blank=True)
def __str__(self):
return self.nome
class Meta:
abstract = True
verbose_name = 'Parlamentar'
verbose_name_plural = 'Parlamentares'
@python_2_unicode_compatible
class Senador(Parlamentar):
def __str__(self):
return self.nome
class Meta:
verbose_name = 'Senador'
verbose_name_plural = 'Senadores'
@python_2_unicode_compatible
class Deputado(Parlamentar):
def __str__(self):
return self.nome
class Meta:
verbose_name = 'Deputado'
verbose_name_plural = 'Deputados'
@python_2_unicode_compatible
class Comissao(models.Model):
id_api = models.IntegerField('ID na API da casa')
nome = models.CharField('Nome', max_length=255)
sigla = models.CharField('Sigla', max_length=255)
link = models.URLField(blank=True)
tipo = models.CharField('Tipo', max_length=255)
class Meta:
verbose_name = "Comissão"
verbose_name_plural = "Comissões"
def __str__(self):
return '{} - {}'.format(self.nome, self.origem)
@property
def origem(self):
camara = self.__dict__.get('_comissaocamaracache')
return 'Câmara' if camara else 'Senado'
@python_2_unicode_compatible
class ComissaoSenado(Comissao):
def __str__(self):
return '{} - Senado'.format(self.nome)
class Meta:
verbose_name = 'Comissão do Senado'
verbose_name_plural = 'Comissões do Senado'
@python_2_unicode_compatible
class ComissaoCamara(Comissao):
def __str__(self):
return '{} - Câmara'.format(self.nome)
class Meta:
verbose_name = 'Comissão da Câmara'
verbose_name_plural = 'Comissões da Câmara'
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.
......@@ -55,6 +55,7 @@ INSTALLED_APPS = [
'agenda.apps.AgendaConfig',
'graph.apps.GraphConfig',
'api.apps.ApiConfig',
'parlamento.apps.ParlamentoConfig',
]
if DEBUG:
......
......@@ -18,7 +18,7 @@ import datetime
from django import forms
from main.models import Projeto, Tag
from agenda.models import Comissao
from parlamento.models import ComissaoCamara, ComissaoSenado
ORIGEM_DEFAULT = "Todas"
......@@ -28,12 +28,10 @@ def get_comissoes():
return (
("", "Todas"),
("Senado", tuple(
Comissao.objects.filter(
origem=Projeto.SENADO).values_list('id', 'nome')),
ComissaoSenado.objects.all().values_list('id', 'nome')),
),
("Câmara", tuple(
Comissao.objects.filter(
origem=Projeto.CAMARA).values_list('id', 'nome')),
ComissaoCamara.objects.all().values_list('id', 'nome')),
),
)
......
......@@ -51,7 +51,7 @@ class TestAgendaDaSemanaView(TestCase):
{"data": "13/09/2017", "origem": "SE"})
eventos_esperados = Evento.objects.\
na_mesma_semana_que_o_dia(datetime.date(2017, 9, 13))\
.filter(comissao__origem="SE").order_by("data")
.filter(comissao__comissaosenado__isnull=False).order_by("data")
self.assertEqual(list(eventos_esperados),
list(response.context["object_list"]))
......
......@@ -29,8 +29,9 @@ from django.http import JsonResponse, Http404
from haystack.generic_views import FacetedSearchView
from agenda.models import Comissao, Evento
from agenda.models import Evento
from main.models import Projeto, Tramitacao
from parlamento.models import Comissao
from website.models import WebsiteOptions
from graph.core import generate_graph
......@@ -199,7 +200,13 @@ class Agenda(ViewListagemSemanal):
def get_queryset(self):
qs = Evento.objects.na_mesma_semana_que_o_dia(self.date)
if self.deve_filtrar_pela_origem():
qs = qs.filter(comissao__origem=self._origem)
origens = {
'SE': 'comissaosenado',
'CA': 'comissaocamara',
}
origem = origens[self._origem]
filtro = {'comissao__{}__isnull'.format(origem): False}
qs = qs.filter(**filtro)
return qs
......