From 4aa0e5c3b89ae9839e35360ccec59cd7906b770a Mon Sep 17 00:00:00 2001 From: Victor Fabre Date: Thu, 20 Sep 2018 12:18:49 -0300 Subject: [PATCH] fix #1827 (#2234) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [WIP - DON'T MERGE] fix #1827 * Adiciona parâmetros necessários para mostrar DebugToolbar --- requirements/dev-requirements.txt | 2 +- requirements/requirements.txt | 23 ++++++++++------------- sapl/base/tests/teststub_urls.py | 8 +++----- sapl/comissoes/tests/test_comissoes.py | 1 + sapl/materia/forms.py | 2 +- sapl/sessao/forms.py | 2 +- sapl/sessao/views.py | 18 +++++++++++++++--- sapl/settings.py | 15 ++++++++------- sapl/test_urls.py | 2 +- sapl/urls.py | 6 ++++++ 10 files changed, 47 insertions(+), 32 deletions(-) diff --git a/requirements/dev-requirements.txt b/requirements/dev-requirements.txt index 49ded787e..dba8788b2 100644 --- a/requirements/dev-requirements.txt +++ b/requirements/dev-requirements.txt @@ -2,7 +2,7 @@ autopep8==1.2.4 beautifulsoup4==4.6.0 -django-debug-toolbar==1.5 +django-debug-toolbar==1.8 ipdb==0.10.1 pdbpp==0.9.2 pip-review==0.4 diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 6d9d79d66..f93a0ee00 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,24 +1,21 @@ dj-database-url==0.4.1 django-haystack==2.6.0 -django>=1.9,<1.10 -# TODO O django-admin-bootstrapped 2.5.7 não inseriu a mudança que permite -# a compatibilidade com Django 1.9+. A linha abaixo será mudada quando uma -# nova versão do django-admin-bootstrapped for lançada -git+git://github.com/django-admin-bootstrapped/django-admin-bootstrapped.git +django>=1.10,<1.11 +git+git://github.com/rubgombar1/django-admin-bootstrapped.git django-bootstrap3==7.0.1 -django-bower==5.1.0 +django-bower==5.2.0 django-braces==1.9.0 django-compressor==2.0 -django-crispy-forms==1.6.0 -django-extensions==1.6.7 -django-extra-views==0.8.0 +django-crispy-forms==1.6.1 +django-extensions==1.9.8 +django-extra-views==0.11.0 django-filter==0.15.3 django-floppyforms==1.6.2 -django-model-utils==2.5 -django-sass-processor==0.5.4 +django-model-utils==3.1.1 +django-sass-processor==0.5.8 djangorestframework==3.4.0 -drfdocs==0.0.11 -easy-thumbnails==2.3 +git+git://github.com/jasperlittle/django-rest-framework-docs +easy-thumbnails==2.5 django-image-cropping==1.1.0 git+git://github.com/interlegis/trml2pdf.git libsass==0.11.1 diff --git a/sapl/base/tests/teststub_urls.py b/sapl/base/tests/teststub_urls.py index 9796768f2..8b66d6586 100644 --- a/sapl/base/tests/teststub_urls.py +++ b/sapl/base/tests/teststub_urls.py @@ -1,11 +1,9 @@ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic.base import TemplateView from sapl.urls import urlpatterns as original_patterns -ptrn = patterns('', - url(r'^zzzz$', +ptrn = [url(r'^zzzz$', TemplateView.as_view( - template_name='index.html'), name='zzzz')) - + template_name='index.html'), name='zzzz')] urlpatterns = original_patterns + ptrn diff --git a/sapl/comissoes/tests/test_comissoes.py b/sapl/comissoes/tests/test_comissoes.py index 4d12ba810..d2f8b0bd1 100644 --- a/sapl/comissoes/tests/test_comissoes.py +++ b/sapl/comissoes/tests/test_comissoes.py @@ -74,6 +74,7 @@ def test_incluir_comissao_submit(admin_client): 'nome': 'Comissão Teste', 'sigla': 'CT', 'data_criacao': '2016-03-22', + 'unidade_deliberativa': True, 'salvar': 'salvar'}, follow=True) assert response.status_code == 200 diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index c353b862f..4853ef45a 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1161,7 +1161,7 @@ class TipoProposicaoSelect(Select): str(data_has_perfil), force_text(option_label)) - def render_options(self, choices, selected_choices): + def render_options(self, selected_choices): # Normalize to strings. selected_choices = set(force_text(v) for v in selected_choices) output = [] diff --git a/sapl/sessao/forms.py b/sapl/sessao/forms.py index f7308f62e..a5d86e8fd 100644 --- a/sapl/sessao/forms.py +++ b/sapl/sessao/forms.py @@ -422,7 +422,7 @@ class VotacaoForm(forms.Form): class VotacaoNominalForm(forms.Form): resultado_votacao = forms.ModelChoiceField(label='Resultado da Votação', - required=True, + required=False, queryset=TipoResultadoVotacao.objects.all()) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 32813f84a..f9317c0d7 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -1838,9 +1838,6 @@ class VotacaoNominalAbstract(SessaoPermissionMixin): except ObjectDoesNotExist: raise Http404() - if 'cancelar-votacao' in request.POST: - fechar_votacao_materia(materia_votacao) - return self.form_valid(form) if form.is_valid(): votos_sim = 0 @@ -1848,6 +1845,21 @@ class VotacaoNominalAbstract(SessaoPermissionMixin): abstencoes = 0 nao_votou = 0 + if 'cancelar-votacao' in request.POST: + fechar_votacao_materia(materia_votacao) + if self.ordem: + return HttpResponseRedirect(reverse( + 'sapl.sessao:ordemdia_list', kwargs={'pk': kwargs['pk']})) + else: + return HttpResponseRedirect(reverse( + 'sapl.sessao:expedientemateria_list', + kwargs={'pk': kwargs['pk']})) + else: + if form.cleaned_data['resultado_votacao'] == None: + form.add_error(None, 'Não é possível finalizar a votação sem ' + 'nenhum resultado da votação') + return self.form_invalid(form) + for votos in request.POST.getlist('voto_parlamentar'): v = votos.split(':') voto = v[0] diff --git a/sapl/settings.py b/sapl/settings.py index 12865c501..aa17fe3b7 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -116,11 +116,7 @@ HAYSTACK_CONNECTIONS = { }, } - -if DEBUG: - INSTALLED_APPS += ('debug_toolbar', 'rest_framework_docs',) - -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = [ 'reversion.middleware.RevisionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', @@ -131,8 +127,13 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', - # 'speedinfo.middleware.ProfilerMiddleware', # Bug na versão 1.9 -) + 'speedinfo.middleware.ProfilerMiddleware', +] +if DEBUG: + INSTALLED_APPS += ('debug_toolbar', 'rest_framework_docs',) + MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ] + INTERNAL_IPS = ('127.0.0.1') + CACHES = { 'default': { diff --git a/sapl/test_urls.py b/sapl/test_urls.py index 851b1995b..23e0c9544 100644 --- a/sapl/test_urls.py +++ b/sapl/test_urls.py @@ -56,7 +56,7 @@ def create_perms_post_migrate(sapl_app_config): ctype = ContentType.objects.get_for_model(klass) ctypes.add(ctype) - for perm in _get_all_permissions(klass._meta, ctype): + for perm in _get_all_permissions(klass._meta): searched_perms.append((ctype, perm)) all_perms = set(Permission.objects.filter( diff --git a/sapl/urls.py b/sapl/urls.py index 07f382013..904b4357e 100644 --- a/sapl/urls.py +++ b/sapl/urls.py @@ -70,6 +70,12 @@ urlpatterns = [ # http://stackoverflow.com/questions/35510373/ if settings.DEBUG: + import debug_toolbar + + urlpatterns += [ + url(r'^__debug__/', include(debug_toolbar.urls)), + + ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)