Browse Source

impl feature flag superficial

pull/3357/head
Leandro Roberto 5 years ago
parent
commit
efa15f32d2
  1. 3
      sapl/base/forms.py
  2. 18
      sapl/base/migrations/0044_appconfig_sapl_as_sapn.py
  3. 5
      sapl/base/models.py
  4. 36
      sapl/base/urls.py
  5. 9
      sapl/base/views.py
  6. 19
      sapl/compilacao/migrations/0018_auto_20210227_2152.py
  7. 3
      sapl/compilacao/models.py
  8. 7
      sapl/context_processors.py
  9. 3
      sapl/norma/urls.py
  10. 3
      sapl/norma/views.py
  11. 3
      sapl/templates/base/layouts.yaml
  12. 29
      sapl/templates/search/search.html
  13. 9
      sapl/urls.py
  14. 7
      sapl/utils.py

3
sapl/base/forms.py

@ -1611,7 +1611,8 @@ class ConfiguracoesAppForm(ModelForm):
'tramitacao_materia',
'tramitacao_documento',
'google_recaptcha_site_key',
'google_recaptcha_secret_key']
'google_recaptcha_secret_key',
'sapl_as_sapn']
def __init__(self, *args, **kwargs):
super(ConfiguracoesAppForm, self).__init__(*args, **kwargs)

18
sapl/base/migrations/0044_appconfig_sapl_as_sapn.py

@ -0,0 +1,18 @@
# Generated by Django 2.2.13 on 2021-02-28 00:45
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0043_auto_20210203_1442'),
]
operations = [
migrations.AddField(
model_name='appconfig',
name='sapl_as_sapn',
field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], default=False, verbose_name='Utilizar SAPL com SAPN?'),
),
]

5
sapl/base/models.py

@ -200,6 +200,11 @@ class AppConfig(models.Model):
verbose_name=_('Chave privada gerada pelo Google Recaptcha'),
max_length=256, default='')
sapl_as_sapn = models.BooleanField(
verbose_name=_(
'Utilizar SAPL como SAPN?'),
choices=YES_NO_CHOICES, default=False)
class Meta:
verbose_name = _('Configurações da Aplicação')
verbose_name_plural = _('Configurações da Aplicação')

36
sapl/base/urls.py

@ -11,7 +11,8 @@ from django.views.generic.base import RedirectView, TemplateView
from sapl.base.views import (AutorCrud, ConfirmarEmailView, TipoAutorCrud, get_estatistica, DetailUsuarioView,
PesquisarAutorView, RecuperarSenhaEmailView, RecuperarSenhaFinalizadoView,
RecuperarSenhaConfirmaView, RecuperarSenhaCompletoView, RelatorioMateriaAnoAssuntoView)
RecuperarSenhaConfirmaView, RecuperarSenhaCompletoView, RelatorioMateriaAnoAssuntoView,
IndexView)
from sapl.settings import EMAIL_SEND_USER, MEDIA_URL, LOGOUT_REDIRECT_URL
from .apps import AppConfig
@ -35,10 +36,14 @@ app_name = AppConfig.name
admin_user = [
url(r'^sistema/usuario/$', PesquisarUsuarioView.as_view(), name='usuario'),
url(r'^sistema/usuario/create$', CreateUsuarioView.as_view(), name='user_create'),
url(r'^sistema/usuario/(?P<pk>\d+)$', DetailUsuarioView.as_view(), name='user_detail'),
url(r'^sistema/usuario/(?P<pk>\d+)/edit$', EditUsuarioView.as_view(), name='user_edit'),
url(r'^sistema/usuario/(?P<pk>\d+)/delete$', DeleteUsuarioView.as_view(), name='user_delete')
url(r'^sistema/usuario/create$',
CreateUsuarioView.as_view(), name='user_create'),
url(r'^sistema/usuario/(?P<pk>\d+)$',
DetailUsuarioView.as_view(), name='user_detail'),
url(r'^sistema/usuario/(?P<pk>\d+)/edit$',
EditUsuarioView.as_view(), name='user_edit'),
url(r'^sistema/usuario/(?P<pk>\d+)/delete$',
DeleteUsuarioView.as_view(), name='user_delete')
]
alterar_senha = [
@ -49,17 +54,23 @@ alterar_senha = [
]
recuperar_senha = [
url(r'^recuperar-senha/email/$', RecuperarSenhaEmailView.as_view(), name='recuperar_senha_email'),
url(r'^recuperar-senha/finalizado/$', RecuperarSenhaFinalizadoView.as_view(), name='recuperar_senha_finalizado'),
url(r'^recuperar-senha/email/$', RecuperarSenhaEmailView.as_view(),
name='recuperar_senha_email'),
url(r'^recuperar-senha/finalizado/$',
RecuperarSenhaFinalizadoView.as_view(), name='recuperar_senha_finalizado'),
url(r'^recuperar-senha/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', RecuperarSenhaConfirmaView.as_view(),
name='recuperar_senha_confirma'),
url(r'^recuperar-senha/completo/$', RecuperarSenhaCompletoView.as_view(), name='recuperar_senha_completo'),
url(r'^recuperar-senha/completo/$',
RecuperarSenhaCompletoView.as_view(), name='recuperar_senha_completo'),
]
urlpatterns = [
url(r'^$', IndexView.as_view(template_name='index.html')),
url(r'^sistema/autor/tipo/', include(TipoAutorCrud.get_urls())),
url(r'^sistema/autor/', include(AutorCrud.get_urls())),
url(r'^sistema/autor/pesquisar-autor/', PesquisarAutorView.as_view(), name='pesquisar_autor'),
url(r'^sistema/autor/pesquisar-autor/',
PesquisarAutorView.as_view(), name='pesquisar_autor'),
url(r'^sistema/ajuda/(?P<topic>\w+)$',
HelpTopicView.as_view(), name='help_topic'),
@ -70,7 +81,7 @@ urlpatterns = [
url(r'^sistema/app-config/', include(AppConfigCrud.get_urls())),
# TODO mover estas telas para a app 'relatorios'
url(r'^sistema/relatorios/$',
url(r'^sistema/relatorios/$',
RelatoriosListView.as_view(), name='relatorios_list'),
url(r'^sistema/relatorios/materia-por-autor$',
RelatorioMateriasPorAutorView.as_view(), name='materia_por_autor'),
@ -174,9 +185,10 @@ urlpatterns = [
(TemplateView.as_view(template_name='sistema.html')),
name='sistema'),
url(r'^login/$', views.LoginView.as_view(template_name= 'base/login.html', authentication_form= LoginForm),
url(r'^login/$', views.LoginView.as_view(template_name='base/login.html', authentication_form=LoginForm),
name='login'),
url(r'^logout/$', views.LogoutView.as_view(), {'next_page': LOGOUT_REDIRECT_URL}, name='logout'),
url(r'^logout/$', views.LogoutView.as_view(),
{'next_page': LOGOUT_REDIRECT_URL}, name='logout'),
url(r'^sistema/search/', SaplSearchView(), name='haystack_search'),

9
sapl/base/views.py

@ -60,7 +60,7 @@ from sapl.sessao.models import (
from sapl.settings import EMAIL_SEND_USER
from sapl.utils import (gerar_hash_arquivo, intervalos_tem_intersecao, mail_service_configured, parlamentares_ativos,
SEPARADOR_HASH_PROPOSICAO, show_results_filter_set, num_materias_por_tipo,
google_recaptcha_configured)
google_recaptcha_configured, sapl_as_sapn)
from .forms import (AlterarSenhaForm, CasaLegislativaForm, ConfiguracoesAppForm, RelatorioAtasFilterSet,
RelatorioAudienciaFilterSet, RelatorioDataFimPrazoTramitacaoFilterSet,
@ -77,6 +77,13 @@ def get_casalegislativa():
return CasaLegislativa.objects.first()
class IndexView(TemplateView):
def get(self, request, *args, **kwargs):
if sapl_as_sapn():
return redirect('/norma/pesquisar')
return TemplateView.get(self, request, *args, **kwargs)
class ConfirmarEmailView(TemplateView):
template_name = "email/confirma.html"

19
sapl/compilacao/migrations/0018_auto_20210227_2152.py

@ -0,0 +1,19 @@
# Generated by Django 2.2.13 on 2021-02-28 00:52
from django.db import migrations
import image_cropping.fields
class Migration(migrations.Migration):
dependencies = [
('compilacao', '0017_auto_20210225_1127'),
]
operations = [
migrations.AlterField(
model_name='dispositivo',
name='imagem_cropping',
field=image_cropping.fields.ImageRatioField('imagem', '100x100', adapt_rotation=False, allow_fullsize=False, free_crop=True, help_text='O recorte de imagem é possível após a atualização.', hide_image_field=False, size_warning=True, verbose_name='Recorte de Imagem'),
),
]

3
sapl/compilacao/models.py

@ -1192,8 +1192,7 @@ class Dispositivo(BaseModel, TimestampedMixin):
imagem = ImageCropField(
verbose_name=_('Imagem'),
upload_to=imagem_upload_path,
validators=[restringe_tipos_de_arquivo_img], null=True, blank=True)
upload_to=imagem_upload_path, null=True, blank=True)
imagem_cropping = ImageRatioField(
'imagem', '100x100', verbose_name=_('Recorte de Imagem'),

7
sapl/context_processors.py

@ -3,7 +3,8 @@ import logging
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from sapl.utils import google_recaptcha_configured as google_recaptcha_configured_utils
from sapl.utils import google_recaptcha_configured as google_recaptcha_configured_utils,\
sapl_as_sapn as sapl_as_sapn_utils
from sapl.utils import mail_service_configured as mail_service_configured_utils
@ -37,8 +38,8 @@ def google_recaptcha_configured(request):
def sapl_as_sapn(request):
return {
'sapl_as_sapn': settings.SAPL_AS_SAPN,
'sapl_as_sapn': sapl_as_sapn_utils(),
'nome_sistema': _('Sistema de Apoio ao Processo Legislativo')
if not settings.SAPL_AS_SAPN
if not sapl_as_sapn_utils()
else _('Sistema de Apoio a Publicação de Normas')
}

3
sapl/norma/urls.py

@ -8,6 +8,7 @@ from sapl.norma.views import (AnexoNormaJuridicaCrud, AssuntoNormaCrud,
recuperar_numero_norma, AutoriaNormaCrud,
PesquisarAssuntoNormaView)
from .apps import AppConfig
@ -33,7 +34,7 @@ urlpatterns = [
url(r'^sistema/norma/vinculo/', include(
TipoVinculoNormaJuridicaCrud.get_urls())),
url(r'^norma/pesquisar$' if not settings.SAPL_AS_SAPN else r'^$',
url(r'^norma/pesquisar$',
NormaPesquisaView.as_view(), name='norma_pesquisa'),
url(r'^norma/recuperar-norma$', recuperar_norma, name="recuperar_norma"),

3
sapl/norma/views.py

@ -26,7 +26,8 @@ from sapl.base.models import AppConfig
from sapl.compilacao.views import IntegracaoTaView
from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux,
MasterDetailCrud, make_pagination)
from sapl.utils import show_results_filter_set, get_client_ip
from sapl.utils import show_results_filter_set, get_client_ip,\
sapl_as_sapn
from .forms import (AnexoNormaJuridicaForm, NormaFilterSet, NormaJuridicaForm,
NormaPesquisaSimplesForm, NormaRelacionadaForm,

3
sapl/templates/base/layouts.yaml

@ -13,8 +13,7 @@ CasaLegislativa:
AppConfig:
{% trans 'Configurações Gerais' %}:
- esfera_federacao
- documentos_administrativos
- esfera_federacao documentos_administrativos sapl_as_sapn
#{% trans 'Módulo Parlamentares' %}:

29
sapl/templates/search/search.html

@ -12,19 +12,22 @@
</div>
</div>
<div class="row">
<div class="col-md-8">
<h3> Em quais tipos de documento deseja pesquisar?</h3>
<br/>
<div class="checkbox" id="check_all">
<label for="id_check_all">
<input type="checkbox" id="id_check_all" onchange="checkAll(this)" /> Marcar/Desmarcar Todos
</label>
{% if not sapl_as_sapn %}
<div class="row">
<div class="col-md-8">
<h3> Em quais tipos de documento deseja pesquisar?</h3>
<br/>
<div class="checkbox" id="check_all">
<label for="id_check_all">
<input type="checkbox" id="id_check_all" onchange="checkAll(this)" /> Marcar/Desmarcar Todos
</label>
</div>
<br/>
{{ form.models }}
</div>
<br/>
{{ form.models }}
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-12">
@ -117,8 +120,8 @@
function checkAll(elem) {
let checkboxes = document.getElementsByName('models');
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox')
checkboxes[i].checked = elem.checked;
if (checkboxes[i].type == 'checkbox')
checkboxes[i].checked = elem.checked;
}
}
</script>

9
sapl/urls.py

@ -38,6 +38,10 @@ import sapl.sessao.urls
urlpatterns = []
if not settings.SAPL_AS_SAPN:
urlpatterns = [
]
urlpatterns += [
url(r'^message$', TemplateView.as_view(template_name='base.html')),
url(r'^admin/', admin.site.urls),
@ -54,8 +58,8 @@ urlpatterns += [
url(r'', include(sapl.relatorios.urls)),
url(r'', include(sapl.audiencia.urls)),
url(r'^$', TemplateView.as_view(template_name='index.html'),
name='sapl_index'),
# url(r'^$', TemplateView.as_view(template_name='index.html'),
# name='sapl_index'),
# must come at the end
# so that base /sistema/ url doesn't capture its children
url(r'', include(sapl.base.urls)),
@ -69,6 +73,7 @@ urlpatterns += [
path("robots.txt", TemplateView.as_view(
template_name="robots.txt", content_type="text/plain")),
]

7
sapl/utils.py

@ -6,6 +6,7 @@ from operator import itemgetter
import os
import platform
import re
import sys
import tempfile
from time import time
from unicodedata import normalize as unicodedata_normalize
@ -27,6 +28,7 @@ from django.db import models
from django.db.models import Q
from django.forms import BaseForm
from django.forms.widgets import SplitDateTimeWidget
from django.urls.base import clear_url_caches
from django.utils import six, timezone
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
@ -1019,6 +1021,11 @@ def google_recaptcha_configured():
return not AppConfig.attr('google_recaptcha_site_key') == ''
def sapl_as_sapn():
from sapl.base.models import AppConfig
return AppConfig.attr('sapl_as_sapn')
def timing(f):
@wraps(f)
def wrap(*args, **kw):

Loading…
Cancel
Save