Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #265 from giovanisleite/giovani-create-chamber-of-…
Browse files Browse the repository at this point in the history
…deputies-app

Create chamber_of_deputies app
  • Loading branch information
cuducos authored Oct 28, 2017
2 parents dc0f5bc + fa2053e commit 57b55b6
Show file tree
Hide file tree
Showing 56 changed files with 681 additions and 443 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ ratings:
- "**.sh"

exclude_paths:
- "jarbas/core/migrations/"
- "**/migrations/"
- "**/tests/*.py"
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[run]
source = jarbas
omit =
jarbas/api/tests/*.py
jarbas/chamber_of_deputies/tests/*.py
jarbas/chamber_of_deputies/migrations/*.py
jarbas/core/migrations/*.py
jarbas/core/tests/*.py
jarbas/frontend/tests/*.py
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ Each `Reimbursement` object is a reimbursement claimed by a congressperson and i

#### Retrieving a specific reimbursement

##### `GET /api/reimbursement/<document_id>/`
##### `GET /api/chamber_of_deputies/reimbursement/<document_id>/`

Details from a specific reimbursement. If `receipt_url` wasn't fetched yet, the server **won't** try to fetch it automatically.

##### `GET /api/reimbursement/<document_id>/receipt/`
##### `GET /api/chamber_of_deputies/reimbursement/<document_id>/receipt/`

URL of the digitalized version of the receipt of this specific reimbursement.

If `receipt_url` wasn't fetched yet, the server **will** try to fetch it automatically.

If you append the parameter `force` (i.e. `GET /api/reimbursement/<document_id>/receipt/?force=1`) the server will re-fetch the receipt URL.
If you append the parameter `force` (i.e. `GET /api/chamber_of_deputies/reimbursement/<document_id>/receipt/?force=1`) the server will re-fetch the receipt URL.

Not all receipts are available, so this URL can be `null`.

#### Listing reimbursements

##### `GET /api/reimbursement/`
##### `GET /api/chamber_of_deputies/reimbursement/`

Lists all reimbursements.

Expand All @@ -72,7 +72,7 @@ All these endpoints accepts any combination of the following parameters:
For example:

```
GET /api/reimbursement/?year=2016&cnpj_cpf=11111111111111&subquota_id=42&order_by=probability
GET /api/chamber_of_deputies/reimbursement/?year=2016&cnpj_cpf=11111111111111&subquota_id=42&order_by=probability
```

This request will list:
Expand All @@ -84,7 +84,7 @@ This request will list:

Also you can pass more than one value per field (e.g. `document_id=111111,222222`).

##### `GET /api/reimbursement/<document_id>/same_day/`
##### `GET /api/chamber_of_deputies/reimbursement/<document_id>/same_day/`

Lists all reimbursements of expenses from the same day as `document_id`.

Expand All @@ -94,27 +94,27 @@ Subqoutas are categories of expenses that can be reimbursed by congresspeople.

#### Listing subquotas

##### `GET /api/subquota/`
##### `GET /api/chamber_of_deputies/subquota/`

Lists all subquotas names and IDs.

##### Filtering

Accepts a case-insensitve `LIKE` filter in as the `q` URL parameter (e.g. `GET /api/subquota/?q=meal` list all applicant that have `meal` in their names.
Accepts a case-insensitve `LIKE` filter in as the `q` URL parameter (e.g. `GET /api/chamber_of_deputies/subquota/?q=meal` list all applicant that have `meal` in their names.

### Applicant

An applicant is the person (congressperson or theleadership of aparty or government) who claimed the reimbursemement.

#### List applicants

##### `GET /api/applicant/`
##### `GET /api/chamber_of_deputies/applicant/`

Lists all names of applicants together with their IDs.

##### Filtering

Accepts a case-insensitve `LIKE` filter in as the `q` URL parameter (e.g. `GET /api/applicant/?q=lideranca` list all applicant that have `lideranca` in their names.
Accepts a case-insensitve `LIKE` filter in as the `q` URL parameter (e.g. `GET /api/chamber_of_deputies/applicant/?q=lideranca` list all applicant that have `lideranca` in their names.

### Company

Expand Down Expand Up @@ -217,12 +217,12 @@ $ docker-compose run --rm django python manage.py suspicions /mnt/data/suspicion
$ docker-compose run --rm django python manage.py tweets
```

If you're interesting in having a database full of data you can get the datasets running [Rosie](https://github.com/datasciencebr/rosie).
If you're interesting in having a database full of data you can get the datasets running [Rosie](https://github.com/datasciencebr/rosie).
To add a fresh new `reimbursements.xz` or `suspicions.xz` brewed by [Rosie](https://github.com/datasciencebr/rosie), or a `companies.xz` you've got from the [toolbox](https://github.com/datasciencebr/serenata-toolbox), you just need copy these files to `contrib/data` and refer to them inside the container from the path `/mnt/data/`.

#### Acessing Jabas

You can access it at [`localhost:8000`](http://localhost:8000/) in development mode or [`localhost`](http://localhost:80/) in production mode.
You can access it at [`localhost:8000`](http://localhost:8000/) in development mode or [`localhost`](http://localhost:80/) in production mode.


```console
Expand Down Expand Up @@ -309,4 +309,4 @@ If you would like to access the Django Admin for an alternative view of the reim

```console
$ python manage.py createsuperuser
```
```
File renamed without changes.
6 changes: 6 additions & 0 deletions jarbas/chamber_of_deputies/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ChamberOfDeputiesConfig(AppConfig):
name = 'jarbas.chamber_of_deputies'
verbose_name = 'Câmara dos Deputados - Cota para Exercício da Atividade Parlamentar'
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.core.management.base import BaseCommand
from requests.exceptions import ConnectionError

from jarbas.core.models import Reimbursement
from jarbas.chamber_of_deputies.models import Reimbursement


class Command(BaseCommand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from bulk_update.helper import bulk_update

from jarbas.core.management.commands import LoadCommand
from jarbas.core.models import Reimbursement
from jarbas.chamber_of_deputies.models import Reimbursement


class Command(LoadCommand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from jarbas.core.fields import DateAsStringField, IntegerField
from jarbas.core.management.commands import LoadCommand
from jarbas.core.models import Reimbursement
from jarbas.core.tasks import create_or_update_reimbursement
from jarbas.chamber_of_deputies.models import Reimbursement
from jarbas.chamber_of_deputies.tasks import create_or_update_reimbursement


class Command(LoadCommand):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.core.management.base import BaseCommand
from django.contrib.postgres.search import SearchVector

from jarbas.core.models import Reimbursement
from jarbas.chamber_of_deputies.models import Reimbursement


class Command(BaseCommand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from bulk_update.helper import bulk_update

from jarbas.core.management.commands import LoadCommand
from jarbas.core.models import Reimbursement
from jarbas.chamber_of_deputies.models import Reimbursement


class Command(LoadCommand):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.core.management.base import BaseCommand

from jarbas.core.models import Reimbursement, Tweet
from jarbas.chamber_of_deputies.models import Reimbursement, Tweet


class Command(BaseCommand):
Expand Down
157 changes: 157 additions & 0 deletions jarbas/chamber_of_deputies/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-14 07:45
from __future__ import unicode_literals

from django.conf import settings
import django.contrib.postgres.fields.jsonb
import django.contrib.postgres.indexes
import django.contrib.postgres.search
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0041_migrate_data_to_chamber_of_deputies_app'),
]

state_operations = [
migrations.CreateModel(
name='HistoricalReimbursement',
fields=[
('id', models.IntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
('document_id', models.IntegerField(db_index=True, verbose_name='Número do Reembolso')),
('last_update', models.DateTimeField(blank=True, db_index=True, editable=False, verbose_name='Atualizado no Jarbas em')),
('available_in_latest_dataset', models.BooleanField(default=True, verbose_name='Disponível na Câmara dos Deputados')),
('year', models.IntegerField(db_index=True, verbose_name='Ano')),
('applicant_id', models.IntegerField(db_index=True, verbose_name='Identificador do Solicitante')),
('total_reimbursement_value', models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, verbose_name='Valor da Restituição')),
('total_net_value', models.DecimalField(decimal_places=3, max_digits=10, verbose_name='Valor Líquido')),
('reimbursement_numbers', models.CharField(max_length=140, verbose_name='Números dos Ressarcimentos')),
('net_values', models.CharField(max_length=140, verbose_name='Valores Líquidos dos Ressarcimentos')),
('congressperson_id', models.IntegerField(blank=True, null=True, verbose_name='Identificador Único do Parlamentar')),
('congressperson_name', models.CharField(blank=True, db_index=True, max_length=140, null=True, verbose_name='Nome do Parlamentar')),
('congressperson_document', models.IntegerField(blank=True, null=True, verbose_name='Número da Carteira Parlamentar')),
('party', models.CharField(blank=True, max_length=7, null=True, verbose_name='Partido')),
('state', models.CharField(blank=True, db_index=True, max_length=2, null=True, verbose_name='UF')),
('term_id', models.IntegerField(blank=True, null=True, verbose_name='Código da Legislatura')),
('term', models.IntegerField(blank=True, null=True, verbose_name='Número da Legislatura')),
('subquota_id', models.IntegerField(db_index=True, verbose_name='Número da Subcota')),
('subquota_description', models.CharField(db_index=True, max_length=140, verbose_name='Descrição da Subcota')),
('subquota_group_id', models.IntegerField(blank=True, null=True, verbose_name='Número da Especificação da Subcota')),
('subquota_group_description', models.CharField(blank=True, max_length=140, null=True, verbose_name='Descrição da Especificação da Subcota')),
('supplier', models.CharField(max_length=140, verbose_name='Fornecedor')),
('cnpj_cpf', models.CharField(blank=True, db_index=True, max_length=14, null=True, verbose_name='CNPJ ou CPF')),
('document_type', models.IntegerField(verbose_name='Indicativo de Tipo de Documento Fiscal')),
('document_number', models.CharField(blank=True, max_length=140, null=True, verbose_name='Número do Documento')),
('document_value', models.DecimalField(decimal_places=3, max_digits=10, verbose_name='Valor do Documento')),
('issue_date', models.DateField(db_index=True, verbose_name='Data de Emissão')),
('month', models.IntegerField(db_index=True, verbose_name='Mês')),
('remark_value', models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, verbose_name='Valor da Glosa')),
('installment', models.IntegerField(blank=True, null=True, verbose_name='Número da Parcela')),
('batch_number', models.IntegerField(verbose_name='Número do Lote')),
('reimbursement_values', models.CharField(blank=True, max_length=140, null=True, verbose_name='Valores dos Ressarcimentos')),
('passenger', models.CharField(blank=True, max_length=140, null=True, verbose_name='Passageiro')),
('leg_of_the_trip', models.CharField(blank=True, max_length=140, null=True, verbose_name='Trecho')),
('probability', models.DecimalField(blank=True, decimal_places=5, max_digits=6, null=True, verbose_name='Probabilidade')),
('suspicions', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True, verbose_name='Suspeitas')),
('receipt_fetched', models.BooleanField(db_index=True, default=False, verbose_name='Tentamos acessar a URL do documento fiscal?')),
('receipt_url', models.CharField(blank=True, max_length=140, null=True, verbose_name='URL do Documento Fiscal')),
('receipt_text', models.TextField(blank=True, null=True, verbose_name='Texto do Recibo')),
('search_vector', django.contrib.postgres.search.SearchVectorField(null=True)),
('history_id', models.AutoField(primary_key=True, serialize=False)),
('history_date', models.DateTimeField()),
('history_type', models.CharField(choices=[('+', 'Criado'), ('~', 'Modificado'), ('-', 'Excluído')], max_length=1)),
],
options={
'get_latest_by': 'history_date',
'ordering': ('-history_date', '-history_id'),
'verbose_name': 'historical reembolso',
'db_table': 'chamber_of_deputies_historicalreimbursement',
},
),
migrations.CreateModel(
name='Reimbursement',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('document_id', models.IntegerField(db_index=True, unique=True, verbose_name='Número do Reembolso')),
('last_update', models.DateTimeField(auto_now=True, db_index=True, verbose_name='Atualizado no Jarbas em')),
('available_in_latest_dataset', models.BooleanField(default=True, verbose_name='Disponível na Câmara dos Deputados')),
('year', models.IntegerField(db_index=True, verbose_name='Ano')),
('applicant_id', models.IntegerField(db_index=True, verbose_name='Identificador do Solicitante')),
('total_reimbursement_value', models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, verbose_name='Valor da Restituição')),
('total_net_value', models.DecimalField(decimal_places=3, max_digits=10, verbose_name='Valor Líquido')),
('reimbursement_numbers', models.CharField(max_length=140, verbose_name='Números dos Ressarcimentos')),
('net_values', models.CharField(max_length=140, verbose_name='Valores Líquidos dos Ressarcimentos')),
('congressperson_id', models.IntegerField(blank=True, null=True, verbose_name='Identificador Único do Parlamentar')),
('congressperson_name', models.CharField(blank=True, db_index=True, max_length=140, null=True, verbose_name='Nome do Parlamentar')),
('congressperson_document', models.IntegerField(blank=True, null=True, verbose_name='Número da Carteira Parlamentar')),
('party', models.CharField(blank=True, max_length=7, null=True, verbose_name='Partido')),
('state', models.CharField(blank=True, db_index=True, max_length=2, null=True, verbose_name='UF')),
('term_id', models.IntegerField(blank=True, null=True, verbose_name='Código da Legislatura')),
('term', models.IntegerField(blank=True, null=True, verbose_name='Número da Legislatura')),
('subquota_id', models.IntegerField(db_index=True, verbose_name='Número da Subcota')),
('subquota_description', models.CharField(db_index=True, max_length=140, verbose_name='Descrição da Subcota')),
('subquota_group_id', models.IntegerField(blank=True, null=True, verbose_name='Número da Especificação da Subcota')),
('subquota_group_description', models.CharField(blank=True, max_length=140, null=True, verbose_name='Descrição da Especificação da Subcota')),
('supplier', models.CharField(max_length=140, verbose_name='Fornecedor')),
('cnpj_cpf', models.CharField(blank=True, db_index=True, max_length=14, null=True, verbose_name='CNPJ ou CPF')),
('document_type', models.IntegerField(verbose_name='Indicativo de Tipo de Documento Fiscal')),
('document_number', models.CharField(blank=True, max_length=140, null=True, verbose_name='Número do Documento')),
('document_value', models.DecimalField(decimal_places=3, max_digits=10, verbose_name='Valor do Documento')),
('issue_date', models.DateField(db_index=True, verbose_name='Data de Emissão')),
('month', models.IntegerField(db_index=True, verbose_name='Mês')),
('remark_value', models.DecimalField(blank=True, decimal_places=3, max_digits=10, null=True, verbose_name='Valor da Glosa')),
('installment', models.IntegerField(blank=True, null=True, verbose_name='Número da Parcela')),
('batch_number', models.IntegerField(verbose_name='Número do Lote')),
('reimbursement_values', models.CharField(blank=True, max_length=140, null=True, verbose_name='Valores dos Ressarcimentos')),
('passenger', models.CharField(blank=True, max_length=140, null=True, verbose_name='Passageiro')),
('leg_of_the_trip', models.CharField(blank=True, max_length=140, null=True, verbose_name='Trecho')),
('probability', models.DecimalField(blank=True, decimal_places=5, max_digits=6, null=True, verbose_name='Probabilidade')),
('suspicions', django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True, verbose_name='Suspeitas')),
('receipt_fetched', models.BooleanField(db_index=True, default=False, verbose_name='Tentamos acessar a URL do documento fiscal?')),
('receipt_url', models.CharField(blank=True, max_length=140, null=True, verbose_name='URL do Documento Fiscal')),
('receipt_text', models.TextField(blank=True, null=True, verbose_name='Texto do Recibo')),
('search_vector', django.contrib.postgres.search.SearchVectorField(null=True)),
],
options={
'verbose_name_plural': 'reembolsos',
'ordering': ('-year', '-issue_date'),
'verbose_name': 'reembolso',
'db_table': 'chamber_of_deputies_reimbursement',
},
),
migrations.CreateModel(
name='Tweet',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.DecimalField(db_index=True, decimal_places=0, max_digits=25, verbose_name='Tweet ID')),
('reimbursement', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='chamber_of_deputies.Reimbursement')),
],
options={
'ordering': ('-status',),
'db_table': 'chamber_of_deputies_tweet',
},
),
migrations.AddIndex(
model_name='reimbursement',
index=django.contrib.postgres.indexes.GinIndex(fields=['search_vector'], name='chamber_of__search__10d8b3_gin'),
),
migrations.AlterIndexTogether(
name='reimbursement',
index_together=set([('year', 'issue_date', 'id')]),
),
migrations.AddField(
model_name='historicalreimbursement',
name='history_user',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL),
),
]

operations = [
migrations.SeparateDatabaseAndState(state_operations=state_operations)
]
Empty file.
Loading

0 comments on commit 57b55b6

Please sign in to comment.