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 %} -