From 86793f1ad9e33a64258390ada7ffb436c24ebc3c Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Wed, 16 Mar 2016 21:00:58 -0300 Subject: [PATCH] Define namespace em urls.py via app_name --- base/__init__.py | 2 +- base/apps.py | 4 ++-- base/urls.py | 3 +++ comissoes/__init__.py | 2 +- comissoes/apps.py | 4 ++-- comissoes/urls.py | 6 ++++++ compilacao/apps.py | 4 ++-- compilacao/urls.py | 4 ++++ crud/tests/stub_app/urls.py | 2 +- crud/tests/test_base.py | 11 ++++++----- crud/urls.py | 5 +++++ lexml/__init__.py | 2 +- lexml/apps.py | 4 ++-- lexml/urls.py | 4 ++++ materia/__init__.py | 2 +- materia/apps.py | 4 ++-- materia/urls.py | 4 ++++ norma/__init__.py | 2 +- norma/apps.py | 4 ++-- norma/urls.py | 4 ++++ painel/__init__.py | 1 + painel/apps.py | 7 +++++++ painel/urls.py | 3 +++ parlamentares/__init__.py | 2 +- parlamentares/apps.py | 4 ++-- parlamentares/urls.py | 4 ++++ protocoloadm/__init__.py | 2 +- protocoloadm/apps.py | 4 ++-- protocoloadm/urls.py | 4 ++++ relatorios/__init__.py | 1 + relatorios/apps.py | 7 +++++++ relatorios/urls.py | 3 +++ sessao/__init__.py | 2 +- sessao/apps.py | 4 ++-- sessao/urls.py | 4 ++++ 35 files changed, 97 insertions(+), 32 deletions(-) create mode 100644 crud/urls.py create mode 100644 painel/apps.py create mode 100644 relatorios/apps.py diff --git a/base/__init__.py b/base/__init__.py index 579b5a023..bbf993376 100644 --- a/base/__init__.py +++ b/base/__init__.py @@ -1 +1 @@ -default_app_config = 'base.apps.BaseAppConfig' +default_app_config = 'base.apps.AppConfig' diff --git a/base/apps.py b/base/apps.py index e11a474b4..cb73158bb 100644 --- a/base/apps.py +++ b/base/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class BaseAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'base' verbose_name = _('Dados Básicos') diff --git a/base/urls.py b/base/urls.py index f7806f843..4ddb4532a 100644 --- a/base/urls.py +++ b/base/urls.py @@ -2,8 +2,11 @@ from django.conf.urls import url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.generic.base import TemplateView +from .apps import AppConfig from .views import CasaLegislativaTableAuxView, HelpView +app_name = AppConfig.name + urlpatterns = [ url(r'^sistema/', TemplateView.as_view(template_name='sistema.html')), url(r'^ajuda/(?P\w+)$', HelpView.as_view(), name='help_topic'), diff --git a/comissoes/__init__.py b/comissoes/__init__.py index 76fa7e087..78f813284 100644 --- a/comissoes/__init__.py +++ b/comissoes/__init__.py @@ -1 +1 @@ -default_app_config = 'comissoes.apps.ComissoesAppConfig' +default_app_config = 'comissoes.apps.AppConfig' diff --git a/comissoes/apps.py b/comissoes/apps.py index 906f1d04b..e37de82c1 100644 --- a/comissoes/apps.py +++ b/comissoes/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class ComissoesAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'comissoes' verbose_name = _('Comissões') diff --git a/comissoes/urls.py b/comissoes/urls.py index bff625ee0..6a7e44ef4 100644 --- a/comissoes/urls.py +++ b/comissoes/urls.py @@ -7,6 +7,10 @@ from comissoes.views import (CadastrarComissaoView, CargoCrud, ComissaoCrud, PeriodoComposicaoCrud, ReunioesView, TipoComissaoCrud) +from .apps import AppConfig + +app_name = AppConfig.name + comissao_url_patterns = ComissaoCrud.get_urls() + [ url(r'^(?P\d+)/composicao$', ComposicaoView.as_view(), name='composicao'), @@ -26,6 +30,8 @@ comissao_url_patterns = ComissaoCrud.get_urls() + [ CadastrarComissaoView.as_view(), name='cadastrar_comissao'), ] +app_name = AppConfig.name + urlpatterns = [ url(r'^comissoes/', include(comissao_url_patterns)), diff --git a/compilacao/apps.py b/compilacao/apps.py index 8cab3c8fb..5d56706ba 100644 --- a/compilacao/apps.py +++ b/compilacao/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class CompilacaoAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'compilacao' verbose_name = _('Compilação') diff --git a/compilacao/urls.py b/compilacao/urls.py index e11fad89c..b3329a16d 100644 --- a/compilacao/urls.py +++ b/compilacao/urls.py @@ -4,6 +4,10 @@ from compilacao import views from compilacao.views import (TipoNotaCrud, TipoPublicacaoCrud, TipoVideCrud, VeiculoPublicacaoCrud) +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns_compilacao = [ url(r'^$', views.TaListView.as_view(), name='ta_list'), url(r'^create$', views.TaCreateView.as_view(), name='ta_create'), diff --git a/crud/tests/stub_app/urls.py b/crud/tests/stub_app/urls.py index 3224f5c1a..66f7fed14 100644 --- a/crud/tests/stub_app/urls.py +++ b/crud/tests/stub_app/urls.py @@ -3,5 +3,5 @@ from django.conf.urls import include, url from .views import CountryCrud urlpatterns = [ - url(r'^countries/', include(CountryCrud.get_urls())), + url(r'^countries/', include(CountryCrud.get_urls(), 'stub_app')), ] diff --git a/crud/tests/test_base.py b/crud/tests/test_base.py index 2021b8447..f8379fb8a 100644 --- a/crud/tests/test_base.py +++ b/crud/tests/test_base.py @@ -140,11 +140,12 @@ def test_layout_detail_fieldsets(monkeypatch): def test_reverse(): - 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,)) + assert '/countries/' == reverse('stub_app:country_list') + assert '/countries/create' == reverse('stub_app:country_create') + assert '/countries/2' == reverse('stub_app:country_detail', args=(2,)) + assert '/countries/2/edit' == reverse('stub_app:country_update', args=(2,)) + assert '/countries/2/delete' == reverse( + 'stub_app:country_delete', args=(2,)) def assert_h1(res, title): diff --git a/crud/urls.py b/crud/urls.py new file mode 100644 index 000000000..8b7da50fe --- /dev/null +++ b/crud/urls.py @@ -0,0 +1,5 @@ +from django.conf.urls import include, url + +urlpatterns = [ + url(r'', include('stub_app.urls')), +] diff --git a/lexml/__init__.py b/lexml/__init__.py index 4a85a35ba..b9a440a35 100644 --- a/lexml/__init__.py +++ b/lexml/__init__.py @@ -1 +1 @@ -default_app_config = 'lexml.apps.LexmlAppConfig' +default_app_config = 'lexml.apps.AppConfig' diff --git a/lexml/apps.py b/lexml/apps.py index b72fc8ea3..4098530b0 100644 --- a/lexml/apps.py +++ b/lexml/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class LexmlAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'lexml' verbose_name = _('LexML') diff --git a/lexml/urls.py b/lexml/urls.py index 43935a8b1..08258d079 100644 --- a/lexml/urls.py +++ b/lexml/urls.py @@ -2,6 +2,10 @@ from django.conf.urls import include, url from lexml.views import LexmlProvedorCrud, LexmlPublicadorCrud +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns = [ url(r'^sistema/lexml/provedor/', include(LexmlProvedorCrud.get_urls())), diff --git a/materia/__init__.py b/materia/__init__.py index 269adab59..7d2cd33d2 100644 --- a/materia/__init__.py +++ b/materia/__init__.py @@ -1 +1 @@ -default_app_config = 'materia.apps.MateriaAppConfig' +default_app_config = 'materia.apps.AppConfig' diff --git a/materia/apps.py b/materia/apps.py index 2c6d5591b..759206443 100644 --- a/materia/apps.py +++ b/materia/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class MateriaAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'materia' verbose_name = _('Matéria') diff --git a/materia/urls.py b/materia/urls.py index c19477a72..128cbc103 100644 --- a/materia/urls.py +++ b/materia/urls.py @@ -22,6 +22,10 @@ from materia.views import (AcompanhamentoConfirmarView, TramitacaoEditView, TramitacaoView, UnidadeTramitacaoCrud) +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns = [ url(r'^materia/', include(MateriaLegislativaCrud.get_urls())), diff --git a/norma/__init__.py b/norma/__init__.py index 6254dc544..5c4701e00 100644 --- a/norma/__init__.py +++ b/norma/__init__.py @@ -1 +1 @@ -default_app_config = 'norma.apps.NormaAppConfig' +default_app_config = 'norma.apps.AppConfig' diff --git a/norma/apps.py b/norma/apps.py index 14856aa71..424c2e996 100644 --- a/norma/apps.py +++ b/norma/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class NormaAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'norma' verbose_name = _('Norma Jurídica') diff --git a/norma/urls.py b/norma/urls.py index 0085740df..d68fd36a5 100644 --- a/norma/urls.py +++ b/norma/urls.py @@ -4,6 +4,10 @@ from norma.views import (AssuntoNormaCrud, NormaEditView, NormaIncluirView, NormaPesquisaView, NormaTaView, NormaTemporarioCrud, PesquisaNormaListView, TipoNormaCrud) +from .apps import AppConfig + +app_name = AppConfig.name + # @LeandroRoberto comentou em # https://github.com/interlegis/sapl/pull/255#discussion_r55894269 # diff --git a/painel/__init__.py b/painel/__init__.py index e69de29bb..1eedfa389 100644 --- a/painel/__init__.py +++ b/painel/__init__.py @@ -0,0 +1 @@ +default_app_config = 'painel.apps.AppConfig' diff --git a/painel/apps.py b/painel/apps.py new file mode 100644 index 000000000..1b46b6eba --- /dev/null +++ b/painel/apps.py @@ -0,0 +1,7 @@ +from django import apps +from django.utils.translation import ugettext_lazy as _ + + +class AppConfig(apps.AppConfig): + name = 'painel' + verbose_name = _('Painel Eletrônico') diff --git a/painel/urls.py b/painel/urls.py index 1c7ad55f3..b210bff05 100644 --- a/painel/urls.py +++ b/painel/urls.py @@ -1,10 +1,13 @@ from django.conf.urls import url +from .apps import AppConfig from .views import controlador_painel # CronometroPainelCrud, from .views import (cronometro_painel, get_dados_painel, painel_mensagem_view, painel_parlamentares_view, painel_view, painel_votacao_view) +app_name = AppConfig.name + urlpatterns = [ url(r'^(?P\d+)/painel$', painel_view, name="painel_principal"), url(r'^painel/(?P\d+)/dados$', get_dados_painel, name='dados_painel'), diff --git a/parlamentares/__init__.py b/parlamentares/__init__.py index 9a89f1ce7..ffec8e2fb 100644 --- a/parlamentares/__init__.py +++ b/parlamentares/__init__.py @@ -1 +1 @@ -default_app_config = 'parlamentares.apps.ParlamentaresAppConfig' +default_app_config = 'parlamentares.apps.AppConfig' diff --git a/parlamentares/apps.py b/parlamentares/apps.py index 0b3610405..6dc201aa3 100644 --- a/parlamentares/apps.py +++ b/parlamentares/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class ParlamentaresAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'parlamentares' verbose_name = _('Parlamentares') diff --git a/parlamentares/urls.py b/parlamentares/urls.py index e853c6908..c7a9f922c 100644 --- a/parlamentares/urls.py +++ b/parlamentares/urls.py @@ -12,6 +12,10 @@ from parlamentares.views import (CargoMesaCrud, ColigacaoCrud, TipoAfastamentoCrud, TipoDependenteCrud, TipoMilitarCrud) +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns = [ url(r'^sistema/parlamentares/legislatura/', include(LegislaturaCrud.get_urls())), diff --git a/protocoloadm/__init__.py b/protocoloadm/__init__.py index 3b0043a9f..c9bbe85bf 100644 --- a/protocoloadm/__init__.py +++ b/protocoloadm/__init__.py @@ -1 +1 @@ -default_app_config = 'protocoloadm.apps.ProtocoloadmAppConfig' +default_app_config = 'protocoloadm.apps.AppConfig' diff --git a/protocoloadm/apps.py b/protocoloadm/apps.py index c163d149c..dbba33948 100644 --- a/protocoloadm/apps.py +++ b/protocoloadm/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class ProtocoloadmAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'protocoloadm' verbose_name = _('Protocolo Administrativo') diff --git a/protocoloadm/urls.py b/protocoloadm/urls.py index 51e98b2f9..6e2103ac0 100644 --- a/protocoloadm/urls.py +++ b/protocoloadm/urls.py @@ -24,6 +24,10 @@ from protocoloadm.views import (AnularProtocoloAdmView, TramitacaoAdministrativoCrud, TramitacaoAdmView, pesquisa_autores) +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns = [ url(r'^protocoloadm/docadm/', include(DocumentoAdministrativoCrud.get_urls())), diff --git a/relatorios/__init__.py b/relatorios/__init__.py index e69de29bb..6f40d706f 100644 --- a/relatorios/__init__.py +++ b/relatorios/__init__.py @@ -0,0 +1 @@ +default_app_config = 'relatorios.apps.AppConfig' diff --git a/relatorios/apps.py b/relatorios/apps.py new file mode 100644 index 000000000..3421e151a --- /dev/null +++ b/relatorios/apps.py @@ -0,0 +1,7 @@ +from django import apps +from django.utils.translation import ugettext_lazy as _ + + +class AppConfig(apps.AppConfig): + name = 'relatorios' + verbose_name = _('Relatórios') diff --git a/relatorios/urls.py b/relatorios/urls.py index ee6fb462c..9dbcbbec0 100644 --- a/relatorios/urls.py +++ b/relatorios/urls.py @@ -1,11 +1,14 @@ from django.conf.urls import url +from .apps import AppConfig from .views import (relatorio_capa_processo, relatorio_documento_administrativo, relatorio_espelho, relatorio_etiqueta_protocolo, relatorio_materia, relatorio_ordem_dia, relatorio_pauta_sessao, relatorio_protocolo, relatorio_sessao_plenaria) +app_name = AppConfig.name + urlpatterns = [ url(r'^relatorios/materia$', relatorio_materia, name='relatorio_materia'), url(r'^relatorios/capa_processo$', diff --git a/sessao/__init__.py b/sessao/__init__.py index 00fc7696d..e036d8daf 100644 --- a/sessao/__init__.py +++ b/sessao/__init__.py @@ -1 +1 @@ -default_app_config = 'sessao.apps.SessaoAppConfig' +default_app_config = 'sessao.apps.AppConfig' diff --git a/sessao/apps.py b/sessao/apps.py index 61cc61856..a222471b8 100644 --- a/sessao/apps.py +++ b/sessao/apps.py @@ -1,7 +1,7 @@ -from django.apps import AppConfig +from django import apps from django.utils.translation import ugettext_lazy as _ -class SessaoAppConfig(AppConfig): +class AppConfig(apps.AppConfig): name = 'sessao' verbose_name = _('Sessão Plenária') diff --git a/sessao/urls.py b/sessao/urls.py index 79a9d471b..0710e74b9 100644 --- a/sessao/urls.py +++ b/sessao/urls.py @@ -21,6 +21,10 @@ from sessao.views import (EditExpedienteOrdemDiaView, EditMateriaOrdemDiaView, VotacaoNominalExpedienteView, VotacaoNominalView, VotacaoView) +from .apps import AppConfig + +app_name = AppConfig.name + urlpatterns_sessao = SessaoCrud.get_urls() + [ url(r'^(?P\d+)/expediente$', ExpedienteView.as_view(), name='expediente'),