diff --git a/comissoes/views.py b/comissoes/views.py
index 41d819bee..673d9edc8 100644
--- a/comissoes/views.py
+++ b/comissoes/views.py
@@ -5,9 +5,9 @@ from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from vanilla import GenericView
+from crud import build_crud
from materia.models import Tramitacao
from parlamentares.models import Filiacao
-from sapl.crud import build_crud
from .forms import (CadastrarComissaoForm, ComposicaoForm,
ParticipacaoCadastroForm)
diff --git a/compilacao/views.py b/compilacao/views.py
index d9f2cc602..4db80bda0 100644
--- a/compilacao/views.py
+++ b/compilacao/views.py
@@ -27,7 +27,7 @@ from compilacao.models import (Dispositivo, Nota,
TextoArticulado, TipoDispositivo, TipoNota,
TipoPublicacao, TipoTextoArticulado, TipoVide,
VeiculoPublicacao, Vide)
-from sapl.crud import NO_ENTRIES_MSG, build_crud, make_pagination
+from crud import NO_ENTRIES_MSG, build_crud, make_pagination
DISPOSITIVO_SELECT_RELATED = (
'tipo_dispositivo',
diff --git a/sapl/crud.py b/crud.py
similarity index 100%
rename from sapl/crud.py
rename to crud.py
diff --git a/sapl/teststubs/__init__.py b/crud_tests/__init__.py
similarity index 100%
rename from sapl/teststubs/__init__.py
rename to crud_tests/__init__.py
diff --git a/crud_tests/models.py b/crud_tests/models.py
new file mode 100644
index 000000000..5540eea7c
--- /dev/null
+++ b/crud_tests/models.py
@@ -0,0 +1,23 @@
+from django.db import models
+
+
+class Continent(models.Model):
+ name = models.CharField(max_length=50)
+
+ def __str__(self):
+ return self.name
+
+
+class Country(models.Model):
+ name = models.CharField(max_length=50)
+ continent = models.ForeignKey(Continent)
+ is_cold = models.BooleanField(choices=[(True, 'Yes'), (False, 'No')])
+ population = models.PositiveIntegerField(blank=True, null=True)
+ description = models.TextField(blank=True)
+
+ class Meta:
+ verbose_name = 'Country'
+ verbose_name_plural = 'Countries'
+
+ def __str__(self):
+ return self.name
diff --git a/crud_tests/settings.py b/crud_tests/settings.py
new file mode 100644
index 000000000..b3d1042dc
--- /dev/null
+++ b/crud_tests/settings.py
@@ -0,0 +1,70 @@
+import os
+
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ # 'NAME': ':memory:',
+ 'NAME': '/tmp/db',
+ },
+}
+
+INSTALLED_APPS = (
+ 'django.contrib.contenttypes',
+ 'django.contrib.auth',
+ 'django.contrib.messages',
+ 'django.contrib.sessions',
+ 'crud_tests',
+ 'crispy_forms',
+)
+
+ROOT_URLCONF = 'crud_tests.urls'
+
+USE_TZ = True
+
+SECRET_KEY = 'zzz...'
+
+TEMPLATES = [{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [os.path.join(BASE_DIR, 'crud_tests/templates'), os.path.join(BASE_DIR, 'templates')],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ "django.core.context_processors.media",
+ "django.core.context_processors.static",
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+}]
+
+STATIC_URL = '/static/'
+
+MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ # 'django.middleware.locale.LocaleMiddleware',
+ # 'django.middleware.common.CommonMiddleware',
+ # 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ # 'django.middleware.security.SecurityMiddleware',
+)
+
+SILENCED_SYSTEM_CHECKS = [
+ '1_7.W001', # Unset MIDDLEWARE_CLASSES warning
+]
+
+
+TIME_ZONE = 'America/Sao_Paulo'
+USE_I18N = True
+USE_L10N = False
+USE_TZ = True
+# DATE_FORMAT = 'N j, Y'
+DATE_FORMAT = 'd/m/Y'
+SHORT_DATE_FORMAT = 'd/m/Y'
+DATE_INPUT_FORMATS = ('%d/%m/%Y', '%m-%d-%Y', '%Y-%m-%d')
diff --git a/crud_tests/templates/base.html b/crud_tests/templates/base.html
new file mode 100644
index 000000000..75b4487c2
--- /dev/null
+++ b/crud_tests/templates/base.html
@@ -0,0 +1,43 @@
+{% load i18n %}
+
+
+
+
+
+
+
+
+
+
+
+ {# Feedback messages #}
+ {% for message in messages %}
+
+
+ {{ message|safe }}
+
+ {% endfor %}
+
+ {# Content header #}
+ {% block base_header %}
+
+
+ {% block title %}
+ {% if view.title %}
+
+ {% endif %}
+ {% endblock %}
+
+
+ {% endblock base_header %}
+
+ {# Content per se #}
+ {% block base_content %}{% endblock %}
+
+
+
+
+
+
diff --git a/sapl/test_crud.py b/crud_tests/test_flux.py
similarity index 57%
rename from sapl/test_crud.py
rename to crud_tests/test_flux.py
index 34da9f34c..47603c952 100644
--- a/sapl/test_crud.py
+++ b/crud_tests/test_flux.py
@@ -2,29 +2,25 @@ import pytest
from django.core.urlresolvers import reverse
from model_mommy import mommy
-from comissoes.models import Comissao, TipoComissao
+from crud import (NO_ENTRIES_MSG, build_crud, from_to, get_field_display,
+ make_pagination)
-from .crud import (NO_ENTRIES_MSG, build_crud, from_to, get_field_display,
- make_pagination)
+from .models import Continent, Country
+from .views import country_crud
pytestmark = pytest.mark.django_db
-# XXX These tests are based on comissoes app
-# but could be done with a stub one
-
@pytest.mark.parametrize("layout, result", [
([['Dados Complementares']], []), # missing rows definition
- ([
- ['Dados Básicos',
- [('nome', 9), ('sigla', 3)],
- [('tipo', 3), ('data_criacao', 3), ('unidade_deliberativa', 3), ]
- ],
- ['Dados Complementares', [('finalidade', 12)]], ],
- ['nome', 'sigla', 'tipo', 'data_criacao', 'unidade_deliberativa']),
+
+ ([['Basic', [('name', 9), ('population', 3)]],
+ ['More Details', [('description', 12)]],
+ ],
+ ['name', 'population']),
])
def test_listview_get_fieldnames(layout, result):
- crud = build_crud(Comissao, 'stub_help_path', layout)
+ crud = build_crud(Country, 'stub_help_path', layout)
view = crud.CrudListView()
assert view.field_names == result
@@ -74,84 +70,66 @@ def test_make_pagination(index, num_pages, result):
def test_get_field_display():
- stub = mommy.prepare(Comissao, unidade_deliberativa=True)
- assert get_field_display(stub, 'nome')[1] == stub.nome
- assert get_field_display(stub, 'tipo')[1] == str(stub.tipo)
+ stub = mommy.prepare(Country, is_cold=True)
+ assert get_field_display(stub, 'name')[1] == stub.name
+ assert get_field_display(stub, 'continent')[1] == str(stub.continent)
# must return choice display, not the value
- assert stub.unidade_deliberativa is True
- assert get_field_display(stub, 'unidade_deliberativa')[1] == 'Sim'
+ assert stub.is_cold is True
+ assert get_field_display(stub, 'is_cold')[1] == 'Yes'
- # None is displayed as empty string
- assert stub.finalidade is None
- assert get_field_display(stub, 'finalidade')[1] == ''
+ # None is displayed as an empty string
+ assert stub.population is None
+ assert get_field_display(stub, 'population')[1] == ''
def test_crud_detail_view_fieldsets(monkeypatch):
- crud = build_crud(
- Comissao, 'stub_help_path', [
-
- ['Dados Básicos',
- [('nome', 9), ('sigla', 3)],
- [('tipo', 3), ('data_criacao', 3), ('unidade_deliberativa', 3), ]
- ],
-
- ['Dados Complementares',
- [('finalidade', 12)]
- ],
- ])
-
- view = crud.CrudDetailView()
- stub = mommy.make(Comissao,
- nome='nome!!!',
- tipo__nome='tipo!!!',
- sigla='sigla!!!',
- data_criacao='2011-01-01',
- unidade_deliberativa=True)
+ view = country_crud.CrudDetailView()
+ stub = mommy.make(Country,
+ name='Brazil',
+ continent__name='South America',
+ is_cold=False)
# to test None displayed as empty string
- assert stub.finalidade is None
+ assert stub.population is None
def get_object():
return stub
monkeypatch.setattr(view, 'get_object', get_object)
assert view.fieldsets == [
- {'legend': 'Dados Básicos',
- 'rows': [[{'id': 'nome',
+ {'legend': 'Basic Data',
+ 'rows': [[{'id': 'name',
'span': 9,
- 'text': 'nome!!!',
- 'verbose_name': 'Nome'},
- {'id': 'sigla',
+ 'text': stub.name,
+ 'verbose_name': 'name'},
+ {'id': 'continent',
'span': 3,
- 'text': 'sigla!!!',
- 'verbose_name': 'Sigla'}],
+ 'text': stub.continent.name,
+ 'verbose_name': 'continent'}
+ ],
- [{'id': 'tipo',
- 'span': 3,
- 'text': 'tipo!!!',
- 'verbose_name': 'Tipo'},
- {'id': 'data_criacao',
- 'span': 3,
- 'text': '2011-01-01',
- 'verbose_name': 'Data de Criação'},
- {'id': 'unidade_deliberativa',
- 'span': 3,
- 'text': 'Sim',
- 'verbose_name': 'Unidade Deliberativa'}]]},
- {'legend': 'Dados Complementares',
- 'rows': [[{'id': 'finalidade',
+ [{'id': 'population',
+ 'span': 6,
+ 'text': '',
+ 'verbose_name': 'population'},
+ {'id': 'is_cold',
+ 'span': 6,
+ 'text': 'No',
+ 'verbose_name': 'is cold'}]]},
+ {'legend': 'More Details',
+ 'rows': [[{'id': 'description',
'span': 12,
'text': '',
- 'verbose_name': 'Finalidade'}]]}]
+ 'verbose_name': 'description'}]]}]
def test_reverse():
- assert '/comissoes/' == reverse('comissao:list')
- assert '/comissoes/create' == reverse('comissao:create')
- assert '/comissoes/2' == reverse('comissao:detail', args=(2,))
- assert '/comissoes/2/edit' == reverse('comissao:update', args=(2,))
- assert '/comissoes/2/delete' == reverse('comissao:delete', args=(2,))
+ assert '/countries/' == reverse('country:list')
+ assert '/countries/create' == reverse('country:create')
+ assert '/countries/2' == reverse('country:detail', args=(2,))
+ assert '/countries/2/edit' == reverse('country:update', args=(2,))
+ assert '/countries/2/delete' == reverse('country:delete', args=(2,))
def assert_h1(res, title):
@@ -162,14 +140,14 @@ NO_ENTRIES_MSG = str(NO_ENTRIES_MSG) # "unlazy"
def assert_on_list_page(res):
- assert_h1(res, 'Comissões')
- assert 'Adicionar Comissão' in res
+ assert_h1(res, 'Countries')
+ assert 'Adicionar Country' in res
assert res.html.find('table') or NO_ENTRIES_MSG in res
# XXX ... characterize better
def assert_on_create_page(res):
- assert_h1(res, 'Adicionar Comissão')
+ assert_h1(res, 'Adicionar Country')
form = res.form
assert not any(
form[k].value for k in form.fields if k != 'csrfmiddlewaretoken')
@@ -182,7 +160,6 @@ def assert_on_detail_page(res, stub_name):
assert 'Excluir' in res
-@pytest.mark.urls('sapl.teststubs.urls_for_list_test')
@pytest.mark.parametrize("num_entries, page_size, ranges, page_list", [
(0, 6, [], []),
(5, 5, [(0, 5)], []),
@@ -194,15 +171,19 @@ def test_flux_list_paginate_detail(
entries_labels = []
for i in range(num_entries):
- # letter = next(letters)
- nome, sigla, tipo = 'nome %s' % i, 'sigla %s' % i, 'tipo %s' % i
- entries_labels.append([nome, sigla, tipo])
- mommy.make(Comissao, nome=nome, sigla=sigla, tipo__nome=tipo)
+ name, continent = 'name %s' % i, 'continent %s' % i
+ population, is_cold = i, i % 2 == 0
+ entries_labels.append([
+ name, continent, str(population), 'Yes' if is_cold else 'No'])
+ mommy.make(Country,
+ name=name,
+ continent__name=continent,
+ population=population,
+ is_cold=is_cold)
- from .teststubs.urls_for_list_test import crud
- crud.CrudListView.paginate_by = page_size
+ country_crud.CrudListView.paginate_by = page_size
- res = app.get('/comissoes/')
+ res = app.get('/countries/')
if num_entries == 0:
assert_on_list_page(res)
@@ -217,7 +198,8 @@ def test_flux_list_paginate_detail(
table = res.html.find('table')
assert table
header, *trs = table.findAll('tr')
- assert header.text.strip().split() == ['Nome', 'Sigla', 'Tipo']
+ assert [c.text for c in header.findChildren('th')] == [
+ 'name', 'continent', 'population', 'is cold']
rows = [[td.text.strip() for td in tr.findAll('td')]
for tr in trs]
@@ -230,38 +212,38 @@ def test_flux_list_paginate_detail(
assert paginator.text.strip().split() == page_list
assert_at_page(res, 1)
- res_detail = res.click('nome 1')
- assert_on_detail_page(res_detail, 'nome 1')
+ res_detail = res.click('name 1')
+ assert_on_detail_page(res_detail, 'name 1')
if len(ranges) > 1:
res = res.click('2', href='page=2')
assert_at_page(res, 2)
- fist_entry_on_2nd_page = 'nome %s' % page_size
+ fist_entry_on_2nd_page = 'name %s' % page_size
res_detail = res.click(fist_entry_on_2nd_page)
assert_on_detail_page(res_detail, fist_entry_on_2nd_page)
res = res.click('1', href='page=1')
assert_at_page(res, 1)
- res_detail = res.click('nome 1')
- assert_on_detail_page(res_detail, 'nome 1')
+ res_detail = res.click('name 1')
+ assert_on_detail_page(res_detail, 'name 1')
@pytest.mark.parametrize("cancel, make_invalid_submit", [
(a, b) for a in (True, False) for b in (True, False)])
def test_flux_list_create_detail(app, cancel, make_invalid_submit):
- # to have a couple an option for tipo field
- stub_tipo = mommy.make(TipoComissao)
+ # to have a couple an option for continent field
+ stub_continent = mommy.make(Continent)
- res = app.get('/comissoes/')
+ res = app.get('/countries/')
# on list page
assert_on_list_page(res)
- res = res.click('Adicionar Comissão')
- previous_objects = set(Comissao.objects.all())
+ res = res.click('Adicionar Country')
+ previous_objects = set(Country.objects.all())
# on create page
assert_on_create_page(res)
@@ -272,7 +254,7 @@ def test_flux_list_create_detail(app, cancel, make_invalid_submit):
# back to list page
assert_on_list_page(res)
# db has not changed
- assert previous_objects == set(Comissao.objects.all())
+ assert previous_objects == set(Country.objects.all())
else:
# and a test detour !
if make_invalid_submit:
@@ -281,34 +263,34 @@ def test_flux_list_create_detail(app, cancel, make_invalid_submit):
'Formulário inválido. O registro não foi criado.' in res
assert_on_create_page(res)
# db has not changed
- assert previous_objects == set(Comissao.objects.all())
+ assert previous_objects == set(Country.objects.all())
# now fill out some fields
form = res.form
- stub_name = '### Nome Especial ###'
- form['nome'] = stub_name
- form['sigla'] = 'SIGLA'
- form['tipo'] = stub_tipo.id
- form['data_criacao'] = '1/1/2001'
+ stub_name = '### name ###'
+ form['name'] = stub_name
+ form['continent'] = stub_continent.id
+ form['population'] = 23000
+ form['is_cold'] = True
res = form.submit()
# on redirect to detail page
- created = Comissao.objects.get(nome=stub_name)
- assert res.url.endswith('/comissoes/%s' % created.id)
+ created = Country.objects.get(name=stub_name)
+ assert res.url.endswith('/countries/%s' % created.id)
res = res.follow()
# on detail page
assert_on_detail_page(res, stub_name)
assert 'Registro criado com sucesso!' in res
- [new_obj] = list(set(Comissao.objects.all()) - previous_objects)
- assert new_obj.nome == stub_name
+ [new_obj] = list(set(Country.objects.all()) - previous_objects)
+ assert new_obj.name == stub_name
def get_detail_page(app):
- stub = mommy.make(Comissao, nome='Comissão Stub')
- res = app.get('/comissoes/%s' % stub.id)
+ stub = mommy.make(Country, name='Country Stub')
+ res = app.get('/countries/%s' % stub.id)
# on detail page
- assert_on_detail_page(res, stub.nome)
+ assert_on_detail_page(res, stub.name)
return stub, res
@@ -318,29 +300,29 @@ def test_flux_detail_update_detail(app, cancel):
res = res.click('Editar')
# on update page
- assert_h1(res, stub.nome)
+ assert_h1(res, stub.name)
# test bifurcation !
if cancel:
res = res.click('Cancelar')
# back to detail page
- assert_on_detail_page(res, stub.nome)
- assert Comissao.objects.get(pk=stub.pk).nome == stub.nome
+ assert_on_detail_page(res, stub.name)
+ assert Country.objects.get(pk=stub.pk).name == stub.name
else:
form = res.form
new_name = '### New Name ###'
- form['nome'] = new_name
+ form['name'] = new_name
res = form.submit()
# on redirect to detail page
- assert res.url.endswith('/comissoes/%s' % stub.id)
+ assert res.url.endswith('/countries/%s' % stub.id)
res = res.follow()
# back to detail page
assert_on_detail_page(res, new_name)
assert 'Registro alterado com sucesso!' in res
- assert Comissao.objects.get(pk=stub.pk).nome == new_name
+ assert Country.objects.get(pk=stub.pk).name == new_name
@pytest.mark.parametrize("cancel", [True, False])
@@ -349,24 +331,24 @@ def test_flux_detail_delete_list(app, cancel):
res = res.click('Excluir')
# on delete page
- assert 'Tem certeza que deseja apagar' in res
- assert stub.nome in res
+ assert 'Confirma exclusão de' in res
+ assert stub.name in res
# test bifurcation !
if cancel:
res = res.click('Cancelar')
# back to detail page
- assert_on_detail_page(res, stub.nome)
- assert Comissao.objects.filter(pk=stub.pk)
+ assert_on_detail_page(res, stub.name)
+ assert Country.objects.filter(pk=stub.pk)
else:
res = res.form.submit()
# on redirect to list page
- assert res.url.endswith('/comissoes/')
+ assert res.url.endswith('/countries/')
res = res.follow()
# on list page
assert 'Registro excluído com sucesso!' in res
- assert_h1(res, 'Comissões')
- assert not Comissao.objects.filter(pk=stub.pk)
+ assert_h1(res, 'Countries')
+ assert not Country.objects.filter(pk=stub.pk)
diff --git a/crud_tests/urls.py b/crud_tests/urls.py
new file mode 100644
index 000000000..b9ba39d7c
--- /dev/null
+++ b/crud_tests/urls.py
@@ -0,0 +1,9 @@
+from django.conf.urls import include, url
+
+from .views import country_crud
+
+urlpatterns = [
+ url(r'^countries/', include(country_crud.urlpatterns,
+ country_crud.namespace,
+ country_crud.namespace)),
+]
diff --git a/crud_tests/views.py b/crud_tests/views.py
new file mode 100644
index 000000000..72393388a
--- /dev/null
+++ b/crud_tests/views.py
@@ -0,0 +1,12 @@
+from crud import build_crud
+
+from .models import Country
+
+country_crud = build_crud(
+ Country, 'help_path', [
+ ['Basic Data',
+ [('name', 9), ('continent', 3)],
+ [('population', 6), ('is_cold', 6)]
+ ],
+ ['More Details', [('description', 12)]],
+ ])
diff --git a/lexml/views.py b/lexml/views.py
index 464b6da3d..b9f0b5a31 100644
--- a/lexml/views.py
+++ b/lexml/views.py
@@ -1,6 +1,6 @@
from django.utils.translation import ugettext_lazy as _
-from sapl.crud import build_crud
+from crud import build_crud
from .models import LexmlProvedor, LexmlPublicador
diff --git a/materia/views.py b/materia/views.py
index 178016862..128176111 100644
--- a/materia/views.py
+++ b/materia/views.py
@@ -12,12 +12,11 @@ from django.views.generic import ListView
from django.views.generic.edit import FormMixin
from vanilla.views import GenericView
-import sapl
from comissoes.models import Comissao, Composicao
from compilacao.views import IntegracaoTaView
+from crud import build_crud, make_pagination
from norma.models import LegislacaoCitada, NormaJuridica, TipoNormaJuridica
from parlamentares.models import Partido
-from sapl.crud import build_crud
from sessao.models import AcompanharMateria
from .forms import (AutoriaForm, DespachoInicialForm, DocumentoAcessorioForm,
@@ -879,12 +878,12 @@ class RelatoriaView(FormMixin, GenericView):
})
else:
relatorias = Relatoria.objects.filter(
- materia_id=kwargs['pk']).order_by(
- '-data_designacao_relator')
+ materia_id=kwargs['pk']).order_by(
+ '-data_designacao_relator')
localizacao = Tramitacao.objects.filter(
- materia=materia).last()
+ materia=materia).last()
comissao = Comissao.objects.get(
- id=localizacao.unidade_tramitacao_destino.comissao.id)
+ id=localizacao.unidade_tramitacao_destino.comissao.id)
if form.is_valid():
relatoria = form.save(commit=False)
@@ -1251,7 +1250,7 @@ class ProposicaoListView(ListView):
paginator = context['paginator']
page_obj = context['page_obj']
- context['page_range'] = sapl.crud.make_pagination(
+ context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
return context
@@ -1434,7 +1433,7 @@ class PesquisaMateriaListView(FormMixin, ListView):
paginator = context['paginator']
page_obj = context['page_obj']
- context['page_range'] = sapl.crud.make_pagination(
+ context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
return context
diff --git a/norma/views.py b/norma/views.py
index 9a630a515..73ea3206b 100644
--- a/norma/views.py
+++ b/norma/views.py
@@ -8,8 +8,8 @@ from django.views.generic.edit import FormMixin
from vanilla.views import GenericView
from compilacao.views import IntegracaoTaView
+from crud import build_crud
from materia.models import MateriaLegislativa, TipoMateriaLegislativa
-from sapl.crud import build_crud
from .forms import NormaJuridicaForm
from .models import (AssuntoNorma, LegislacaoCitada, NormaJuridica,
diff --git a/painel/views.py b/painel/views.py
index 65088386b..0c280cfb5 100644
--- a/painel/views.py
+++ b/painel/views.py
@@ -5,9 +5,9 @@ from django.http import HttpResponse, JsonResponse
from django.shortcuts import render
from django.utils.translation import ugettext_lazy as _
+from crud import build_crud
from painel.models import Painel
from parlamentares.models import Filiacao
-from sapl.crud import build_crud
from sessao.models import (ExpedienteMateria, OrdemDia, PresencaOrdemDia,
RegistroVotacao, SessaoPlenaria,
SessaoPlenariaPresenca, VotoParlamentar)
diff --git a/parlamentares/views.py b/parlamentares/views.py
index fc50d1be6..e39b54447 100644
--- a/parlamentares/views.py
+++ b/parlamentares/views.py
@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic.edit import FormMixin
from vanilla import GenericView
-from sapl.crud import build_crud
+from crud import build_crud
from .forms import (DependenteEditForm, DependenteForm, FiliacaoEditForm,
FiliacaoForm, MandatoEditForm, MandatoForm,
diff --git a/protocoloadm/views.py b/protocoloadm/views.py
index 34156ac95..9e0cc4367 100644
--- a/protocoloadm/views.py
+++ b/protocoloadm/views.py
@@ -15,8 +15,8 @@ from django.views.generic.edit import FormMixin
from vanilla import GenericView
import sapl
+from crud import build_crud, make_pagination
from materia.models import Proposicao, TipoMateriaLegislativa
-from sapl.crud import build_crud
from sapl.utils import create_barcode
from .forms import (AnularProcoloAdmForm, DocumentoAcessorioAdministrativoForm,
@@ -118,7 +118,7 @@ class ProtocoloListView(FormMixin, ListView):
paginator = context['paginator']
page_obj = context['page_obj']
- context['page_range'] = sapl.crud.make_pagination(
+ context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
return context
@@ -322,7 +322,6 @@ class ComprovanteProtocoloView(TemplateView):
numero = self.kwargs['pk']
ano = self.kwargs['ano']
protocolo = Protocolo.objects.get(ano=ano, numero=numero)
-
# numero is string, padd with zeros left via .zfill()
base64_data = create_barcode(numero.zfill(6))
barcode = 'data:image/png;base64,{0}'.format(base64_data)
diff --git a/pytest.ini b/pytest.ini
index 3480351c1..a3b1eef1f 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,6 +1,6 @@
[pytest]
DJANGO_SETTINGS_MODULE=sapl.settings
-norecursedirs = legacy
+norecursedirs = legacy crud_tests
# REUSING DATABASE BY DEFAULT (as a performance optimization)
# http://pytest-django.readthedocs.org/en/latest/database.html#example-work-flow-with-reuse-db-and-create-db
diff --git a/sapl/teststubs/urls_for_list_test.py b/sapl/teststubs/urls_for_list_test.py
deleted file mode 100644
index b09a0d13e..000000000
--- a/sapl/teststubs/urls_for_list_test.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from django.conf.urls import include, url
-
-from comissoes.models import Comissao
-from comissoes.urls import comissao_url_patterns
-from sapl.crud import build_crud
-
-crud = build_crud(
- Comissao, '', [
-
- ['Dados Básicos',
- [('nome', 9), ('sigla', 3)],
- [('tipo', 3)]
- ],
-
- ['Dados Complementares',
- [('finalidade', 12)]
- ],
- ])
-
-urlpatterns = [
- url(r'^comissoes/', include((
- crud.urlpatterns + comissao_url_patterns[len(crud.urlpatterns):],
- crud.namespace, crud.namespace))),
-]
diff --git a/sessao/views.py b/sessao/views.py
index d7a0a9c21..0ac58b2c0 100644
--- a/sessao/views.py
+++ b/sessao/views.py
@@ -11,11 +11,11 @@ from django.views.generic.edit import FormMixin
from rest_framework import generics
import sapl
+from crud import build_crud, make_pagination
from materia.models import (Autoria, DocumentoAcessorio,
TipoMateriaLegislativa, Tramitacao)
from norma.models import NormaJuridica
from parlamentares.models import Parlamentar
-from sapl.crud import build_crud
from sessao.serializers import SessaoPlenariaSerializer
from .forms import (AcompanharMateriaForm, ExpedienteForm, ListMateriaForm,
@@ -2184,7 +2184,7 @@ class SessaoListView(ListView):
paginator = context['paginator']
page_obj = context['page_obj']
- context['page_range'] = sapl.crud.make_pagination(
+ context['page_range'] = make_pagination(
page_obj.number, paginator.num_pages)
return context
diff --git a/test_and_check_qa.sh b/test_and_check_qa.sh
index c7a01989b..c1753337c 100755
--- a/test_and_check_qa.sh
+++ b/test_and_check_qa.sh
@@ -3,4 +3,5 @@
# QA checks: run this before every commit
py.test
-./qa_check.sh
+py.test --ds=crud_tests.settings crud_tests
+./check_qa.sh