From f769e6b108182fe41ab5b212b37820269558323d Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Tue, 28 Aug 2018 18:42:34 -0300 Subject: [PATCH] Fix #2167 (#2178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add campo Esfera Federação na Confiração da Aplicação e trazer esfera ja selecionada ao add norma juridica * ao adcionar norma juridica o campo complementar autocompletado como Não * fix migrations * Delete 0021_appconfig_esfera_federacao.py * Update 0022_auto_20180828_1439.py * update * Delete 0021_auto_20180828_1439.py * Create 0021_appconfig_esfera_federacao.py --- sapl/base/forms.py | 1 + .../0021_appconfig_esfera_federacao.py | 20 +++++++++++++++++++ sapl/base/models.py | 14 ++++++++++++- sapl/norma/views.py | 12 ++++++++++- sapl/templates/base/layouts.yaml | 3 +++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 sapl/base/migrations/0021_appconfig_esfera_federacao.py diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 227037ffd..12cc43564 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -849,6 +849,7 @@ class ConfiguracoesAppForm(ModelForm): model = AppConfig fields = ['documentos_administrativos', 'sequencia_numeracao', + 'esfera_federacao', # 'painel_aberto', # TODO: a ser implementado na versão 3.2 'texto_articulado_proposicao', 'texto_articulado_materia', diff --git a/sapl/base/migrations/0021_appconfig_esfera_federacao.py b/sapl/base/migrations/0021_appconfig_esfera_federacao.py new file mode 100644 index 000000000..a13e312cf --- /dev/null +++ b/sapl/base/migrations/0021_appconfig_esfera_federacao.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2018-08-28 18:16 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0020_auto_20180821_1421'), + ] + + operations = [ + migrations.AddField( + model_name='appconfig', + name='esfera_federacao', + field=models.CharField(blank=True, choices=[('M', 'Municipal'), ('E', 'Estadual'), ('F', 'Federal')], default='', max_length=1, verbose_name='Esfera Federação'), + ), + ] diff --git a/sapl/base/models.py b/sapl/base/models.py index 6e3d2ee67..afd4160ed 100644 --- a/sapl/base/models.py +++ b/sapl/base/models.py @@ -5,7 +5,7 @@ from django.db import models from django.db.models.signals import post_migrate from django.db.utils import DEFAULT_DB_ALIAS from django.utils.translation import ugettext_lazy as _ - +#from model_utils import Choices from sapl.utils import (LISTA_DE_UFS, YES_NO_CHOICES, get_settings_auth_user_model, models_with_gr_for_model) @@ -16,6 +16,11 @@ SEQUENCIA_NUMERACAO = (('A', _('Sequencial por ano')), ('L', _('Sequencial por legislatura')), ('U', _('Sequencial único'))) +ESFERA_FEDERACAO_CHOICES = (('M', _('Municipal')), + ('E', _('Estadual')), + ('F', _('Federal')), +) + @reversion.register() class CasaLegislativa(models.Model): @@ -78,6 +83,13 @@ class AppConfig(models.Model): verbose_name=_('Sequência de numeração'), choices=SEQUENCIA_NUMERACAO, default='A') + esfera_federacao = models.CharField( + max_length=1, + blank=True, + default = "", + verbose_name=_('Esfera Federação'), + choices=ESFERA_FEDERACAO_CHOICES) + # TODO: a ser implementado na versão 3.2 # painel_aberto = models.BooleanField( # verbose_name=_('Painel aberto para usuário anônimo'), diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 80c30a63d..a05d61289 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -13,7 +13,7 @@ from django.views.generic.base import RedirectView from django.views.generic.edit import FormView from django_filters.views import FilterView import weasyprint - +import sapl from sapl.base.models import AppConfig from sapl.compilacao.views import IntegracaoTaView from sapl.crud.base import (RP_DETAIL, RP_LIST, Crud, CrudAux, @@ -196,6 +196,16 @@ class NormaCrud(Crud): def cancel_url(self): return self.search_url + def get_initial(self): + try: + esfera = sapl.base.models.AppConfig.objects.last( + ).esfera_federacao + self.initial['esfera_federacao'] = esfera + except: + pass + self.initial['complemento'] = False + return self.initial + layout_key = 'NormaJuridicaCreate' class ListView(Crud.ListView, RedirectView): diff --git a/sapl/templates/base/layouts.yaml b/sapl/templates/base/layouts.yaml index c07c15036..3f7941d64 100644 --- a/sapl/templates/base/layouts.yaml +++ b/sapl/templates/base/layouts.yaml @@ -14,6 +14,9 @@ AppConfig: {% trans 'Configurações da Aplicação' %}: - documentos_administrativos + {% trans 'Norma Jurídica' %}: + - esfera_federacao + {% trans 'Proposições e Protocolo' %}: - sequencia_numeracao proposicao_incorporacao_obrigatoria receber_recibo_proposicao