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

Create chamber_of_deputies app #265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
49c0f1d
startapp chamber_of_deputies
giovanisleite Oct 14, 2017
aa45708
startapp chamber_of_deputies
giovanisleite Oct 14, 2017
e8d99a3
split core models between core and chamber_of_deputies models
giovanisleite Oct 14, 2017
57d33d0
Register the new app chamber_of_deputies
giovanisleite Oct 14, 2017
10b401e
migrations of the new models
giovanisleite Oct 14, 2017
a997d4a
fix - chamber_of_deputies models diverged
giovanisleite Oct 14, 2017
e2417db
Fix models import paths
giovanisleite Oct 14, 2017
59bfd11
Add permission to dashboard access chamber of deputies Reimbursements
giovanisleite Oct 14, 2017
8bd4c92
Remove unused files from chamber_of_deputies app
giovanisleite Oct 14, 2017
21fbe89
Move Reimbursement querysets to chamber_of_deputies
giovanisleite Oct 14, 2017
5f8b47c
Reflect the permission change at dashboard sites to tests
giovanisleite Oct 14, 2017
c57de74
Move chamber_of_deputies models related samples from core tests to ch…
giovanisleite Oct 14, 2017
2dd28bc
Move chamber models related tests from core to chamber_of_deputies tests
giovanisleite Oct 14, 2017
5e9532c
Move chamber_of_deputies related commands from core to chamber_of_dep…
giovanisleite Oct 14, 2017
012a2fa
Fix commands path to chamber_of_deputies commands
giovanisleite Oct 14, 2017
10f5abc
Move chamber_of_deputies commands tests from core to chamber_of_deput…
giovanisleite Oct 14, 2017
cc2fa83
Data migration
giovanisleite Oct 15, 2017
bb1ad20
Remove spaces from lines almost blank
giovanisleite Oct 17, 2017
2bb9d73
Add migrations folder to Code Climate exclude_paths
giovanisleite Oct 17, 2017
ec0865c
Merge master and solve conflicts
giovanisleite Oct 22, 2017
f3eb7eb
Move tasks to chamber_of_deputies
giovanisleite Oct 22, 2017
f0983db
Remove MagicMock from test_reimbursements_command imports
giovanisleite Oct 22, 2017
3993ff5
Remove blank lines
giovanisleite Oct 22, 2017
48aeac8
Update app's verbose name
giovanisleite Oct 23, 2017
51922a0
Update api endpoints
giovanisleite Oct 23, 2017
c61cd85
Merge branch 'master' into giovani-create-chamber-of-deputies-app
giovanisleite Oct 24, 2017
e7bf9fb
Divide split api.serializers in chamber_of_deputies.serializers and c…
giovanisleite Oct 24, 2017
06b1d82
Update serializers references
giovanisleite Oct 24, 2017
2195384
2 blank lines - pep8 fix
giovanisleite Oct 24, 2017
5fbc8d5
Merge master and solve conflicts
giovanisleite Oct 26, 2017
fb5aa3f
Move api urls and views to chamber of deputies and core
giovanisleite Oct 26, 2017
ea125aa
Update api/chamber_of_deputies urls and related
giovanisleite Oct 26, 2017
cef9e52
Update namespaces related to api
giovanisleite Oct 26, 2017
c0464b1
Move tests from api to chamber_of_deputies and core
giovanisleite Oct 26, 2017
eb6ba52
Remove api folder
giovanisleite Oct 26, 2017
30e050b
Add blank line - pep8
giovanisleite Oct 26, 2017
70cb4d1
Remove api from installed apps
giovanisleite Oct 26, 2017
fa2053e
Omit chamber_of_deputies tests and migrations from coverage
giovanisleite Oct 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```
```
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