From 2ba8a37873b2bbaa61baa074ff6f78b60a058d05 Mon Sep 17 00:00:00 2001 From: Leandro Roberto da Silva Date: Sun, 10 Feb 2019 16:41:56 -0200 Subject: [PATCH] Fix #1540 migra frontend (#2485) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * retira django-bootstrap3 do projeto sapl * retira bower sass-processor e libsass do projeto sapl * altera origem do django-admin-bootstrapped * commenta todas as entradas css e js em base.html * vue create sapl-frontend * add e configura django-webpack-loader * add vue.config.js e configura comunicação com webpack-loader * adequa staticfiles_dirs e ignora webpack-stats * cria bloco de expansão para vue_content * remove rotas do app hellow e impl multiplas entradas * add nova entrada para gereciamento de temas * cria plugin para carregar THEME_CUSTOM em .env * add bootstrap ao projeto e a configuração fixa de temas * add imports básicos para bootstrap * move assets para sapl-frontend * move assets para projetosexterno de tema e configura sapl project para leitura de temas através do .env * remove theme do sapl frontend project * retira link simbólico de entre projeto frontend e projeto de tema * retira scss do projeto django * altera btn-default/bootstrap3 para btn-outline-dark/bootstrap4 * altera btns de outline-dark para outlink-primary * migra pull-right para float-right * migra pull-left para float-left * migra btn-excluir para btn-outline-danger * add global entry and configure jquery * add jquery na entrada global e migra getCookie * remove row-fluid * muda active para link a * ajustes do botão salvar * ajuste botão add participação em comissão * ajuste do layout das mensagens de alerta e botao add detail detail * ajusta script de votação individual * ajuste eslint * altera origem da imagem para etiqueta.png * corrige eslint * migra tela de busca de autores para sapl-frontend * corrige fragmento de html para paginação * ajuste de js e html em protocolo * ajuste de layout no menu protocolo * ajuste no formulário de proposições para sapl_frontend * migra jquery-mask-plugin * remove código antigo do jquery-mask-plugin * migra jquery e algumas funções dependentes * migra tinymce * ajustes eslint * ajuste de sub menus * add campo de hora em mask * move jquery.runner.js para sapl-frontend * primeira versão com jquery runner funcionando * ajusta painel ao sapl-frontend * ajuste de tela de login * cria entr compilação p sapl-frontend e migra jsdiff * migra js das notas * add import bootstrap em module global * altera nome de função para iniciar editor de texto rico * move scss de compilação do tema para o frontend * adequa crud de notas de compilação ao form do django 1.11 * retira render padrão scripts css e js de image_cropping * integra jquery runner e image cropping com jquery e lodash global * ajustes de eslint em compilação * ajuste de layout para notas e de código eslint * ajuste de layout para Vides da app compilação * altera configurações para pasta público de tema ser importada no build * ajustes de eslint * ajusta TAs embedded de normas para sapl-frontend * migra botões de compilação para bootstrap4 * migra componente alert para bootstrap 4 * altera chamada a jQuery e resolve conflito com bootstrap * altera travis.yaml * corrige entrada doo sapl-oficial-theme para instalação trivial * testa modo de definir versão do node no travis * teste de configuração do travis * ajuste de teste e das telas de erro 404 e 500 * Configura sapl-frontend e webpackloader Configura sapl-frontend e webpack-loader com código de produção já esportado para a sapl/static. Desta forma, tanto no travis como no docker não existe a necessidade de instalação de node, npm e/ou yarn * configura docker e localização do webpack-stats.json * inicia migração da edição de dispositivos * ajuste de chunks * resume forma de lidar com com chunks css e js * cria template tag para tratar chunk-vendors * corrige menu de configuração dos TAs * migra barra inferior da vigencia * migra linha do tempo de vigências * ajuste nos menus do topo da edição dinamica da compilação * frontend produção * ajuste de blocos * migra layout da edição dinamica de dispositivos originais * ajuste da seleção de tipos de vigências * migra frontend de edição dinâmica de dispositivos * ajst dropdown de seleção de editor de dispositivos * migra subnav da edição avançada de dispositivos * separa frontend em outro projeto * Altera how-to de instalação do ambiente dev Altera how-to de instalação do ambiente de desenvolvimento com novas instruções para colaboração com o sapl-frontend * migra barra de navegação de parents de dispositivos * Alterações no how-to para colab com sapl-frontend Alterações no how-to para colab com sapl-frontend * ajuste de docs * sapl-frontend reinseriu language pt-br datepicker * ajuste no form autoria multicreate para sapl-frontend * add webpack blocks no index de painel * refatora layout do painel para bootstrap4 * migra cadastro de autor * migra frontend da manutenção de tipos de proposição * migra tela de incorporação * remove templates de compilação * ajusta layout do form de pesquisa textual * ajustes de layout no painel * primeira versão checada do frontend --- .gitignore | 1 + .travis.yml | 2 - Dockerfile | 13 +- docs/instalacao31.rst | 106 +- requirements/requirements.txt | 13 +- sapl/base/forms.py | 8 +- sapl/base/templatetags/common_tags.py | 12 + sapl/base/tests/test_login.py | 8 +- sapl/compilacao/forms.py | 65 +- sapl/crispy_layout_mixin.py | 13 +- sapl/crud/base.py | 2 +- sapl/crud/tests/stub_app/templates/base.html | 4 +- sapl/materia/forms.py | 113 +- .../migrations/0039_auto_20190209_2346.py | 21 + sapl/materia/models.py | 16 +- sapl/materia/views.py | 2 +- sapl/parlamentares/views.py | 4 + sapl/protocoloadm/forms.py | 6 +- sapl/settings.py | 54 +- sapl/static/css/chunk-vendors.f109b7f2.css | 101 + sapl/static/css/compilacao.1e862898.css | 1 + sapl/static/css/global.d2e0a784.css | 1 + sapl/static/css/painel.61177241.css | 1 + sapl/static/fonts/fa-brands-400.3186ebd2.eot | Bin 0 -> 125320 bytes .../static/fonts/fa-brands-400.662c24d0.woff2 | Bin 0 -> 72148 bytes sapl/static/fonts/fa-brands-400.a995bae1.ttf | Bin 0 -> 125016 bytes sapl/static/fonts/fa-brands-400.c7d7a2a1.woff | Bin 0 -> 84568 bytes .../fonts/fa-regular-400.6a9d786e.woff2 | Bin 0 -> 13608 bytes .../static/fonts/fa-regular-400.72f15fa7.woff | Bin 0 -> 16812 bytes sapl/static/fonts/fa-regular-400.80efa56b.eot | Bin 0 -> 34388 bytes sapl/static/fonts/fa-regular-400.fcb220ee.ttf | Bin 0 -> 34092 bytes sapl/static/fonts/fa-solid-900.20c189aa.ttf | Bin 0 -> 186228 bytes sapl/static/fonts/fa-solid-900.3638e62e.woff2 | Bin 0 -> 74320 bytes sapl/static/fonts/fa-solid-900.9a52a4e9.eot | Bin 0 -> 186512 bytes sapl/static/fonts/fa-solid-900.9c73abbd.woff | Bin 0 -> 96248 bytes sapl/static/img/fa-brands-400.e4fed0a5.svg | 3300 ++++++++++++ sapl/static/img/fa-regular-400.304f31f4.svg | 803 +++ sapl/static/img/fa-solid-900.c8ea4c79.svg | 4520 +++++++++++++++++ .../img/ui-icons_2694e8_256x240.274157b3.png | Bin 0 -> 4676 bytes .../img/ui-icons_2e83ff_256x240.602e5d4d.png | Bin 0 -> 4676 bytes .../img/ui-icons_3d80b3_256x240.24fcd129.png | Bin 0 -> 4676 bytes .../img/ui-icons_72a7cf_256x240.55a4c5ce.png | Bin 0 -> 4676 bytes .../img/ui-icons_ffffff_256x240.bb2a88be.png | Bin 0 -> 6487 bytes sapl/static/js/app.js | 252 - sapl/static/js/chunk-vendors.406f40ec.js | 2572 ++++++++++ sapl/static/js/compilacao.9bf86742.js | 240 + sapl/static/js/compilacao.js | 276 - sapl/static/js/compilacao_edit.js | 610 --- sapl/static/js/compilacao_notas.js | 143 - sapl/static/js/compilacao_view.js | 178 - sapl/static/js/global.594a728f.js | 274 + sapl/static/js/jquery.runner.js | 296 -- sapl/static/js/painel.518bdc14.js | 192 + sapl/static/styles/_header.scss | 5 - sapl/static/styles/_home_index.scss | 188 - sapl/static/styles/app.scss | 468 -- sapl/static/styles/compilacao.scss | 1542 ------ sapl/templates/404.html | 46 +- sapl/templates/500.html | 44 +- sapl/templates/auth/user_list.html | 2 +- sapl/templates/base.html | 144 +- .../base/EstatisticasAcessoNormas_filter.html | 4 +- sapl/templates/base/RelatorioAtas_filter.html | 4 +- .../base/RelatorioAudiencia_filter.html | 4 +- ...elatorioDataFimPrazoTramitacao_filter.html | 4 +- .../RelatorioHistoricoTramitacao_filter.html | 4 +- ...latorioMateriasPorAnoAutorTipo_filter.html | 4 +- .../RelatorioMateriasPorAutor_filter.html | 4 +- ...RelatorioMateriasPorTramitacao_filter.html | 4 +- .../base/RelatorioNormaMes_filter.html | 4 +- .../base/RelatorioNormasVigencia_filter.html | 4 +- .../base/RelatorioPresencaSessao_filter.html | 4 +- .../base/RelatorioReuniao_filter.html | 4 +- sapl/templates/base/autor_form.html | 6 +- sapl/templates/base/casalegislativa_list.html | 4 +- sapl/templates/base/login.html | 12 +- .../bootstrap4/layout/formactions.html | 13 + sapl/templates/comissoes/composicao_list.html | 8 +- .../compilacao/ajax_actions_dinamic_edit.html | 133 +- .../ajax_actions_registro_inclusao.html | 2 +- .../templates/compilacao/base_compilacao.html | 12 + .../compilacao/dispositivo_form.html | 62 +- .../dispositivo_form_alteracao.html | 4 +- .../dispositivo_form_definidor_vigencia.html | 2 +- .../dispositivo_form_edicao_basica.html | 2 +- .../compilacao/dispositivo_form_parents.html | 24 +- .../compilacao/dispositivo_form_search.html | 6 +- .../dispositivo_form_search_fragment.html | 2 +- .../compilacao/dispositivo_form_vigencia.html | 2 +- .../layout/bootstrap_btn_checkbox.html | 2 +- sapl/templates/compilacao/messages.html | 4 +- .../compilacao/publicacao_detail.html | 6 +- .../templates/compilacao/publicacao_list.html | 4 +- sapl/templates/compilacao/subnav.html | 25 + sapl/templates/compilacao/text_edit.html | 24 +- .../templates/compilacao/text_edit_bloco.html | 4 +- sapl/templates/compilacao/text_list.html | 96 +- .../compilacao/text_list__embedded.html | 113 +- .../compilacao/text_list__print_version.html | 8 - .../compilacao/text_notificacoes.html | 8 +- .../compilacao/textoarticulado_detail.html | 34 +- .../compilacao/textoarticulado_list.html | 4 +- .../textoarticulado_menu_config.html | 16 +- sapl/templates/crud/confirm_delete.html | 2 +- sapl/templates/crud/detail.html | 20 +- sapl/templates/crud/detail_detail.html | 20 +- sapl/templates/crud/list.html | 8 +- .../floppyforms/image_thumbnail.html | 2 +- sapl/templates/index.html | 361 +- .../materia/adicionar_varias_autorias.html | 4 +- sapl/templates/materia/autoria_list.html | 2 +- .../materia/autoria_multicreate_form.html | 6 +- .../materia/confirmar_proposicao.html | 6 +- .../materia/materialegislativa_detail.html | 2 +- .../materia/materialegislativa_filter.html | 8 +- .../materia/materialegislativa_list.html | 2 +- .../materia/proposicao_confirm_return.html | 4 +- sapl/templates/materia/proposicao_detail.html | 20 +- sapl/templates/materia/proposicao_form.html | 2 +- sapl/templates/materia/relatoria_form.html | 2 +- .../materia/tipoproposicao_form.html | 5 +- sapl/templates/menu_tabelas_auxiliares.yaml | 2 +- sapl/templates/menus/nav.html | 10 +- sapl/templates/menus/subnav.html | 12 +- .../templates/norma/normajuridica_detail.html | 30 +- .../templates/norma/normajuridica_filter.html | 8 +- sapl/templates/paginacao.html | 66 +- sapl/templates/painel/index.html | 180 +- sapl/templates/painel/mensagem.html | 162 +- sapl/templates/painel/parlamentares.html | 60 +- sapl/templates/painel/votacao.html | 199 +- sapl/templates/painel/voto_nominal.html | 24 +- .../parlamentares/composicaomesa_form.html | 10 +- sapl/templates/parlamentares/frente_form.html | 10 +- .../parlamentar_perfil_publico.html | 2 +- .../templates/parlamentares/votante_list.html | 4 +- .../protocoloadm/MateriaTemplate.html | 2 +- .../protocoloadm/anular_protocoloadm.html | 13 +- .../protocoloadm/detail_doc_detail.html | 8 +- .../documentoadministrativo_filter.html | 8 +- .../pesquisa_documento_detail.html | 4 +- .../protocoloadm/proposicoes_detail.html | 10 +- .../protocoloadm/protocolar_documento.html | 19 +- .../protocoloadm/protocolar_materia.html | 14 +- .../protocoloadm/protocolo_filter.html | 17 +- .../protocoloadm/protocolo_list.html | 6 +- .../protocoloadm/protocolo_mostrar.html | 12 +- .../protocoloadm/protocoloadm_detail.html | 33 +- .../tramitacaoadministrativo_detail.html | 8 +- sapl/templates/search/search.html | 208 +- .../adicionar_varias_materias_expediente.html | 8 +- .../adicionar_varias_materias_ordem.html | 8 +- sapl/templates/sessao/expediente.html | 6 +- .../sessao/expedientemateria_form.html | 4 +- .../sessao/expedientemateria_list.html | 4 +- sapl/templates/sessao/mesa.html | 8 +- sapl/templates/sessao/ocorrencia_sessao.html | 2 +- sapl/templates/sessao/ordemdia_list.html | 4 +- sapl/templates/sessao/painel.html | 3 +- .../sessao/sessaoplenaria_filter.html | 12 +- .../templates/sessao/sessaoplenaria_list.html | 2 +- sapl/templates/sessao/votacao/nominal.html | 2 +- .../sessao/votacao/votacao_nominal_bloco.html | 2 +- .../votacao/votacao_simbolica_bloco.html | 2 +- sapl/utils.py | 2 +- setup.py | 13 +- start.sh | 5 - webpack-stats.json | 1 + 168 files changed, 13551 insertions(+), 5506 deletions(-) create mode 100644 sapl/materia/migrations/0039_auto_20190209_2346.py create mode 100644 sapl/static/css/chunk-vendors.f109b7f2.css create mode 100644 sapl/static/css/compilacao.1e862898.css create mode 100644 sapl/static/css/global.d2e0a784.css create mode 100644 sapl/static/css/painel.61177241.css create mode 100644 sapl/static/fonts/fa-brands-400.3186ebd2.eot create mode 100644 sapl/static/fonts/fa-brands-400.662c24d0.woff2 create mode 100644 sapl/static/fonts/fa-brands-400.a995bae1.ttf create mode 100644 sapl/static/fonts/fa-brands-400.c7d7a2a1.woff create mode 100644 sapl/static/fonts/fa-regular-400.6a9d786e.woff2 create mode 100644 sapl/static/fonts/fa-regular-400.72f15fa7.woff create mode 100644 sapl/static/fonts/fa-regular-400.80efa56b.eot create mode 100644 sapl/static/fonts/fa-regular-400.fcb220ee.ttf create mode 100644 sapl/static/fonts/fa-solid-900.20c189aa.ttf create mode 100644 sapl/static/fonts/fa-solid-900.3638e62e.woff2 create mode 100644 sapl/static/fonts/fa-solid-900.9a52a4e9.eot create mode 100644 sapl/static/fonts/fa-solid-900.9c73abbd.woff create mode 100644 sapl/static/img/fa-brands-400.e4fed0a5.svg create mode 100644 sapl/static/img/fa-regular-400.304f31f4.svg create mode 100644 sapl/static/img/fa-solid-900.c8ea4c79.svg create mode 100644 sapl/static/img/ui-icons_2694e8_256x240.274157b3.png create mode 100644 sapl/static/img/ui-icons_2e83ff_256x240.602e5d4d.png create mode 100644 sapl/static/img/ui-icons_3d80b3_256x240.24fcd129.png create mode 100644 sapl/static/img/ui-icons_72a7cf_256x240.55a4c5ce.png create mode 100644 sapl/static/img/ui-icons_ffffff_256x240.bb2a88be.png delete mode 100644 sapl/static/js/app.js create mode 100644 sapl/static/js/chunk-vendors.406f40ec.js create mode 100644 sapl/static/js/compilacao.9bf86742.js delete mode 100644 sapl/static/js/compilacao.js delete mode 100644 sapl/static/js/compilacao_edit.js delete mode 100644 sapl/static/js/compilacao_notas.js delete mode 100644 sapl/static/js/compilacao_view.js create mode 100644 sapl/static/js/global.594a728f.js delete mode 100644 sapl/static/js/jquery.runner.js create mode 100644 sapl/static/js/painel.518bdc14.js delete mode 100644 sapl/static/styles/_header.scss delete mode 100644 sapl/static/styles/_home_index.scss delete mode 100644 sapl/static/styles/app.scss delete mode 100644 sapl/static/styles/compilacao.scss create mode 100644 sapl/templates/bootstrap4/layout/formactions.html create mode 100644 sapl/templates/compilacao/base_compilacao.html create mode 100644 sapl/templates/compilacao/subnav.html create mode 100644 webpack-stats.json diff --git a/.gitignore b/.gitignore index dfdeb2b5c..c656b3b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ __pycache__/ # Nodejs node_modules/ +yarn.lock # Distribution / packaging .Python diff --git a/.travis.yml b/.travis.yml index f54ee6d20..80532c789 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ install: - pip install -r requirements/test-requirements.txt before_script: - - npm install -g bower - cp sapl/.env_test sapl/.env - psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres; - psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres @@ -18,7 +17,6 @@ before_script: script: - ./manage.py migrate - - ./manage.py bower install - py.test --create-db # - ./scripts/django/test_and_check_qa.sh diff --git a/Dockerfile b/Dockerfile index f4953de84..8c2dc0fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 ENV BUILD_PACKAGES postgresql-dev graphviz-dev graphviz build-base git pkgconfig \ python3-dev libxml2-dev jpeg-dev libressl-dev libffi-dev libxslt-dev \ - nodejs npm py3-lxml py3-magic postgresql-client poppler-utils antiword \ + nodejs py3-lxml py3-magic postgresql-client poppler-utils antiword \ curl jq openssh-client vim openssh-client bash RUN apk update --update-cache && apk upgrade @@ -17,9 +17,7 @@ RUN apk add --no-cache python3 nginx tzdata && \ rm -f /etc/nginx/conf.d/* RUN mkdir -p /var/interlegis/sapl && \ - apk add --update --no-cache $BUILD_PACKAGES && \ - npm install -g bower && \ - npm cache verify + apk add --update --no-cache $BUILD_PACKAGES WORKDIR /var/interlegis/sapl/ @@ -37,13 +35,6 @@ COPY config/env_dockerfile /var/interlegis/sapl/sapl/.env # Configura timezone para BRT # RUN cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime && echo "America/Sao_Paulo" > /etc/timezone -# manage.py bower install bug: https://github.com/nvbn/django-bower/issues/51 - -# compilescss - Precompile all occurrences of your SASS/SCSS files for the whole project into css files - -RUN python3 manage.py bower_install --allow-root && \ - python3 manage.py compilescss - RUN python3 manage.py collectstatic --noinput --clear # Remove .env(fake) e sapl.db da imagem diff --git a/docs/instalacao31.rst b/docs/instalacao31.rst index 6e9146ee4..a9752990f 100644 --- a/docs/instalacao31.rst +++ b/docs/instalacao31.rst @@ -28,15 +28,7 @@ Instalar as seguintes dependências do sistema:: pkg-config postgresql postgresql-contrib pgadmin3 python-psycopg2 \ software-properties-common build-essential libxml2-dev libjpeg-dev \ libmysqlclient-dev libssl-dev libffi-dev libxslt1-dev python3-setuptools \ - python3-pip curl poppler-utils antiword default-jre python3-venv - - sudo -i - curl -sL https://deb.nodesource.com/setup_8.x | bash - - exit - sudo apt-get install nodejs - - sudo npm install npm -g - sudo npm install -g bower + python3-pip poppler-utils antiword default-jre python3-venv Instalar o virtualenv usando python 3 para o projeto. ----------------------------------------------------- @@ -153,6 +145,8 @@ Criação da `SECRET_KEY =1.11,<2.0 -django-bootstrap3==11.0.0 django-haystack==2.8.1 django-filter==2.0.0 djangorestframework==3.9.0 dj-database-url==0.5.0 -django-bower==5.2.0 django-braces==1.9.0 django-crispy-forms==1.7.2 django-floppyforms==1.7.0 django-extra-views==0.12.0 django-model-utils==3.1.2 -django-sass-processor==0.7.2 django-reversion==3.0.2 django-reversion-compare==0.8.6 django-speedinfo==1.4.0 django-extensions==2.1.4 django-image-cropping==1.2 +django-webpack-loader==0.6.0 easy-thumbnails==2.5 -libsass==0.17.0 python-decouple==3.1 psycopg2-binary==2.7.6.1 pyyaml==4.2b1 @@ -34,6 +31,10 @@ whoosh==2.7.4 git+git://github.com/interlegis/trml2pdf.git git+git://github.com/jasperlittle/django-rest-framework-docs -git+git://github.com/rubgombar1/django-admin-bootstrapped.git +git+git://github.com/interlegis/django-admin-bootstrapped@custom-for-sapl31 -django-compressor==2.2 \ No newline at end of file +#django-compressor==2.2 +#django-bootstrap3==11.0.0 +#django-bower==5.2.0 +#django-sass-processor==0.7.2 +#libsass==0.17.0 diff --git a/sapl/base/forms.py b/sapl/base/forms.py index f24868ff6..d97ed1804 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -394,7 +394,7 @@ class AutorForm(ModelForm): placeholder=_('Pesquisar por possíveis autores para ' 'o Tipo de Autor selecionado.')), StrictButton( - _('Filtrar'), css_class='btn-default btn-filtrar-autor', + _('Filtrar'), css_class='btn-outline-primary btn-filtrar-autor', type='button')), css_class='hidden', data_action='create', @@ -402,9 +402,9 @@ class AutorForm(ModelForm): data_field='autor_related') autor_select = Row(to_column(('tipo', 3)), - Div(to_column(('nome', 5)), - to_column(('cargo', 4)), - css_class="div_nome_cargo"), + Div(to_column(('nome', 7)), + to_column(('cargo', 5)), + css_class="div_nome_cargo row col"), to_column((autor_related, 9)), to_column((Div( Field('autor_related'), diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 884a6968f..3c72b1654 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -1,5 +1,7 @@ from django import template from django.template.defaultfilters import stringfilter +from django.utils.safestring import mark_safe +from webpack_loader import utils from sapl.base.models import AppConfig from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa, Proposicao @@ -274,3 +276,13 @@ def filiacao_data_filter(parlamentar, data_inicio): @register.filter def filiacao_intervalo_filter(parlamentar, date_range): return filiacao_data(parlamentar, date_range[0], date_range[1]) + + +@register.simple_tag +def render_chunk_vendors(extension=None): + try: + tags = utils.get_as_tags( + 'chunk-vendors', extension=extension, config='DEFAULT', attrs='') + return mark_safe('\n'.join(tags)) + except: + return '' diff --git a/sapl/base/tests/test_login.py b/sapl/base/tests/test_login.py index 91665ea8d..7fe7672e5 100755 --- a/sapl/base/tests/test_login.py +++ b/sapl/base/tests/test_login.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -import pytest from django.contrib.auth import get_user_model +import pytest + pytestmark = pytest.mark.django_db @@ -12,14 +13,15 @@ def user(): def test_login_aparece_na_barra_para_usuario_nao_logado(client): response = client.get('/') - assert '' in str( + assert '' in str( response.content) def test_username_do_usuario_logado_aparece_na_barra(client, user): assert client.login(username='jfirmino', password='123') response = client.get('/') - assert 'Login' not in str(response.content) + assert 'Login' not in str( + response.content) assert 'jfirmino' in str(response.content) assert 'Sair' in str(response.content) diff --git a/sapl/compilacao/forms.py b/sapl/compilacao/forms.py index 3c4275bee..0e4f933d7 100644 --- a/sapl/compilacao/forms.py +++ b/sapl/compilacao/forms.py @@ -23,7 +23,8 @@ from sapl.compilacao.models import (NOTAS_PUBLICIDADE_CHOICES, TipoTextoArticulado, TipoVide, VeiculoPublicacao, Vide) from sapl.compilacao.utils import DISPOSITIVO_SELECT_RELATED -from sapl.crispy_layout_mixin import SaplFormLayout, to_column, to_row +from sapl.crispy_layout_mixin import SaplFormLayout, to_column, to_row,\ + form_actions from sapl.utils import YES_NO_CHOICES error_messages = { @@ -256,19 +257,22 @@ class NotaForm(ModelForm): ]) buttons = FormActions( - HTML('' - '%s' % _('Cancelar')), + *[ + HTML('%s' % _('Cancelar')) + ], Button( 'submit-form', 'Salvar', - css_class='btn btn-primary pull-right') + css_class='btn btn-primary float-right'), + css_class='form-group row justify-content-between mr-1 ml-1' ) self.helper = FormHelper() self.helper.layout = Layout( Div( - Div(HTML(_('Notas')), css_class='panel-heading'), + Div(HTML(_('Notas')), css_class='card-header bg-light'), Div( row1, to_row([(Field( @@ -279,9 +283,9 @@ class NotaForm(ModelForm): placeholder=_('URL Externa (opcional)')), 12)]), row3, to_row([(buttons, 12)]), - css_class="panel-body" + css_class="card-body" ), - css_class="panel panel-primary" + css_class="card" ) ) @@ -328,12 +332,15 @@ class VideForm(ModelForm): def __init__(self, *args, **kwargs): buttons = FormActions( - HTML('' - '%s' % _('Cancelar')), + *[ + HTML('%s' % _('Cancelar')) + ], Button( 'submit-form', 'Salvar', - css_class='btn-primary pull-right') + css_class='btn btn-primary float-right'), + css_class='form-group row justify-content-between mr-1 ml-1' ) dispositivo_ref = Field( @@ -359,15 +366,15 @@ class VideForm(ModelForm): self.helper = FormHelper() self.helper.layout = Layout( Div( - Div(HTML(_('Vides')), css_class='car-header'), + Div(HTML(_('Vides')), css_class='card-header bg-light'), Div( to_column((fields_form[0], 6)), to_column((fields_form[1], 6)), to_column(('dispositivo_base', 0)), to_column(('pk', 0)), - css_class="card-body" + css_class="card-body row" ), - css_class="card bg-light" + css_class="card" ) ) @@ -671,7 +678,7 @@ class DispositivoEdicaoBasicaForm(ModelForm): cancel_label = _('Fechar') more = [ - HTML('%s' % + HTML('%s' % cancel_label), ] @@ -680,7 +687,7 @@ class DispositivoEdicaoBasicaForm(ModelForm): if not (inst.tipo_dispositivo.dispositivo_de_alteracao and inst.tipo_dispositivo.dispositivo_de_articulacao): btns_excluir = [ - HTML('%s' % + HTML('%s' % _('Cancelar')), ] - more.append(Submit('salvar', _('Salvar'), css_class='pull-right')) + more.append(Submit('salvar', _('Salvar'), css_class='float-right')) buttons = FormActions(*more, css_class='form-group') - _fields = [Div(*layout, css_class="row-fluid")] + \ + _fields = [Div(*layout, css_class="row")] + \ [to_row([(buttons, 12)])] self.helper = FormHelper() @@ -1414,14 +1421,14 @@ class DispositivoRegistroRevogacaoForm(Form): layout.append(Field('dispositivo_search_form')) more = [ - HTML('%s' % + HTML('%s' % _('Cancelar')), ] - more.append(Submit('salvar', _('Salvar'), css_class='pull-right')) + more.append(Submit('salvar', _('Salvar'), css_class='float-right')) buttons = FormActions(*more, css_class='form-group') - _fields = [Div(*layout, css_class="row-fluid")] + \ + _fields = [Div(*layout, css_class="row")] + \ [to_row([(buttons, 12)])] self.helper = FormHelper() @@ -1464,14 +1471,14 @@ class DispositivoRegistroInclusaoForm(Form): layout.append(Div(css_class="allowed_inserts col-md-12")) more = [ - HTML('%s' % + HTML('%s' % _('Cancelar')), ] - # more.append(Submit('salvar', _('Salvar'), css_class='pull-right')) + # more.append(Submit('salvar', _('Salvar'), css_class='float-right')) buttons = FormActions(*more, css_class='form-group') - _fields = [Div(*layout, css_class="row-fluid")] + \ + _fields = [Div(*layout, css_class="row")] + \ [to_row([(buttons, 12)])] self.helper = FormHelper() diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index 9b2f0867b..245be6b82 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -1,6 +1,5 @@ from math import ceil -import rtyaml from crispy_forms.bootstrap import FormActions from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit @@ -8,6 +7,7 @@ from django import template from django.core.urlresolvers import reverse, reverse_lazy from django.utils import formats from django.utils.translation import ugettext as _ +import rtyaml def heads_and_tails(list_of_lists): @@ -21,7 +21,7 @@ def to_column(name_span): def to_row(names_spans): - return Div(*map(to_column, names_spans), css_class='row-fluid') + return Div(*map(to_column, names_spans), css_class='row') def to_fieldsets(fields): @@ -35,7 +35,8 @@ def to_fieldsets(fields): def form_actions(more=[Div(css_class='clearfix')], - label=_('Salvar'), name='salvar', css_class='pull-right', disabled=True): + label=_('Salvar'), name='salvar', + css_class='float-right', disabled=True): if disabled: doubleclick = 'this.form.submit();this.disabled=true;' @@ -43,10 +44,12 @@ def form_actions(more=[Div(css_class='clearfix')], doubleclick = 'return true;' return FormActions( + *more, Submit(name, label, css_class=css_class, # para impedir resubmissão do form onclick=doubleclick), - *more) + css_class='form-group row justify-content-between' + ) class SaplFormLayout(Layout): @@ -58,7 +61,7 @@ class SaplFormLayout(Layout): if not buttons: buttons = form_actions(label=save_label, more=[ HTML('%s' % cancel_label) + ' class="btn btn-dark">%s' % cancel_label) if cancel_label else None]) _fields = list(to_fieldsets(fields)) diff --git a/sapl/crud/base.py b/sapl/crud/base.py index faa0e1287..ca5469bf0 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -160,7 +160,7 @@ class ListWithSearchForm(forms.Form): placeholder=_('Filtrar Lista'), css_class='input-lg'), StrictButton( - _('Filtrar'), css_class='btn-default btn-lg', + _('Filtrar'), css_class='btn-outline-primary btn-lg', type='submit')) ) diff --git a/sapl/crud/tests/stub_app/templates/base.html b/sapl/crud/tests/stub_app/templates/base.html index 8a9dc002b..fcf92e5eb 100644 --- a/sapl/crud/tests/stub_app/templates/base.html +++ b/sapl/crud/tests/stub_app/templates/base.html @@ -12,9 +12,9 @@ {# Feedback messages #} {% for message in messages %} -