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 19 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 jarbas/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rest_framework import serializers

from jarbas.core.models import Activity, Reimbursement, Company
from jarbas.chamber_of_deputies.models import Reimbursement
from jarbas.core.models import Activity, Company


class ReimbursementSerializer(serializers.ModelSerializer):
Expand Down
4 changes: 2 additions & 2 deletions jarbas/api/tests/test_applicant_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.shortcuts import resolve_url
from django.test import TestCase

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


class TestApplicant(TestCase):
Expand Down
10 changes: 5 additions & 5 deletions jarbas/api/tests/test_reimbursement_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from mixer.backend.django import mixer

from jarbas.api.tests import get_sample_reimbursement_api_response
from jarbas.core.models import Reimbursement, Tweet
from jarbas.core.tests import random_tweet_status
from jarbas.chamber_of_deputies.models import Reimbursement, Tweet
from jarbas.chamber_of_deputies.tests import random_tweet_status


def get_reimbursement(**kwargs):
Expand Down Expand Up @@ -154,23 +154,23 @@ def setUp(self):
self.url_no_receipt = resolve_url(
'api:reimbursement-receipt', document_id=self.reimbursement_no_receipt.document_id)

@patch('jarbas.core.models.head')
@patch('jarbas.chamber_of_deputies.models.head')
def test_fetch_existing_receipt(self, mocked_head):
mocked_head.return_value.status_code = 200
resp = self.client.get(self.url)
expected = dict(url=self.reimbursement.receipt_url)
content = loads(resp.content.decode('utf-8'))
self.assertEqual(expected, content)

@patch('jarbas.core.models.head')
@patch('jarbas.chamber_of_deputies.models.head')
def test_fetch_non_existing_receipt(self, mocked_head):
mocked_head.return_value.status_code = 404
resp = self.client.get(self.url_no_receipt)
expected = dict(url=None)
content = loads(resp.content.decode('utf-8'))
self.assertEqual(expected, content)

@patch('jarbas.core.models.head')
@patch('jarbas.chamber_of_deputies.models.head')
def test_refetch_existing_receipt(self, mocked_head):
expected = dict(url=self.reimbursement.receipt_url)
self.reimbursement.receipt_fetched = True
Expand Down
6 changes: 4 additions & 2 deletions jarbas/api/tests/test_same_day_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
from django.shortcuts import resolve_url
from django.test import TestCase

from jarbas.core.models import Company, Reimbursement
from jarbas.core.tests import sample_company_data, sample_reimbursement_data
from jarbas.chamber_of_deputies.models import Reimbursement
from jarbas.core.models import Company
from jarbas.chamber_of_deputies.tests import sample_reimbursement_data
from jarbas.core.tests import sample_company_data
from jarbas.api.serializers import format_cnpj


Expand Down
4 changes: 2 additions & 2 deletions jarbas/api/tests/test_subquota_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from django.shortcuts import resolve_url
from django.test import TestCase

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


class TestSubquota(TestCase):
Expand Down
3 changes: 2 additions & 1 deletion jarbas/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from rest_framework.generics import ListAPIView, RetrieveAPIView

from jarbas.api import serializers
from jarbas.core.models import Reimbursement, Company
from jarbas.chamber_of_deputies.models import Reimbursement
from jarbas.core.models import Company


class ReimbursementListView(ListAPIView):
Expand Down
Empty file.
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'
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 @@ -5,7 +5,7 @@
from reprint import output

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
@@ -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