From 94c0a7190fc8ee43b4a34dbf09bafe858bcd4e46 Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Fri, 13 Apr 2018 12:28:51 -0300 Subject: [PATCH 1/5] Fix #1856 (#1866) --- sapl/comissoes/forms.py | 8 +++++++- sapl/comissoes/views.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sapl/comissoes/forms.py b/sapl/comissoes/forms.py index 0a3718b1d..3576873b7 100644 --- a/sapl/comissoes/forms.py +++ b/sapl/comissoes/forms.py @@ -13,10 +13,16 @@ from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar class ComposicaoForm(forms.ModelForm): + comissao = forms.CharField(required=False, label='Comissao', widget=forms.HiddenInput()) + class Meta: model = Composicao exclude = [] + def __init__(self, user=None, **kwargs): + super(ComposicaoForm, self).__init__(**kwargs) + self.fields['comissao'].widget.attrs['disabled'] = 'disabled' + def clean(self): cleaned_data = super(ComposicaoForm, self).clean() @@ -24,7 +30,7 @@ class ComposicaoForm(forms.ModelForm): return cleaned_data periodo = cleaned_data['periodo'] - comissao_pk = cleaned_data['comissao'].id + comissao_pk = self.initial['comissao'].id intersecao_periodo = Composicao.objects.filter( Q(periodo__data_inicio__lte=periodo.data_fim, periodo__data_fim__gte=periodo.data_fim) | diff --git a/sapl/comissoes/views.py b/sapl/comissoes/views.py index 6c47ac6e1..82c3a79c1 100644 --- a/sapl/comissoes/views.py +++ b/sapl/comissoes/views.py @@ -90,6 +90,10 @@ class ComposicaoCrud(MasterDetailCrud): class CreateView(MasterDetailCrud.CreateView): form_class = ComposicaoForm + + def get_initial(self): + comissao = Comissao.objects.get(id=self.kwargs['pk']) + return {'comissao': comissao} class ListView(MasterDetailCrud.ListView): From 90237c2a794490fb7ca4173834253ec20f93f42c Mon Sep 17 00:00:00 2001 From: Victor Fabre Date: Fri, 13 Apr 2018 12:39:18 -0300 Subject: [PATCH 2/5] Fix #1862 (#1867) --- sapl/protocoloadm/forms.py | 31 ++++++++++++++++++++++++++++--- sapl/protocoloadm/views.py | 18 +++++++++++++----- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 9c9485ae4..eff6d09a1 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -308,6 +308,8 @@ class ProtocoloDocumentForm(ModelForm): observacao = forms.CharField(required=False, widget=forms.Textarea, label='Observação') + numero = forms.IntegerField(required=False, label='Número de Protocolo (opcional)') + class Meta: model = Protocolo fields = ['tipo_protocolo', @@ -316,6 +318,7 @@ class ProtocoloDocumentForm(ModelForm): 'assunto', 'interessado', 'observacao', + 'numero' ] def __init__(self, *args, **kwargs): @@ -331,6 +334,8 @@ class ProtocoloDocumentForm(ModelForm): [('interessado', 12)]) row5 = to_row( [('observacao', 12)]) + row6 = to_row( + [('numero', 12)]) self.helper = FormHelper() self.helper.layout = Layout( @@ -341,6 +346,11 @@ class ProtocoloDocumentForm(ModelForm): row4, row5, HTML(" "), + ), + Fieldset(_('Número do Protocolo (Apenas se quiser que a numeração comece ' + 'a partir do número a ser informado)'), + row6, + HTML(" "), form_actions(label=_('Protocolar Documento')) ) ) @@ -385,6 +395,8 @@ class ProtocoloMateriaForm(ModelForm): assunto_ementa = forms.CharField(required=True, widget=forms.Textarea, label='Ementa') + numero = forms.IntegerField(required=False, label='Número de Protocolo (opcional)') + class Meta: model = Protocolo fields = ['tipo_materia', @@ -395,7 +407,8 @@ class ProtocoloMateriaForm(ModelForm): 'observacao', 'numero_materia', 'ano_materia', - 'vincular_materia' + 'vincular_materia', + 'numero' ] def clean_autor(self): @@ -447,12 +460,24 @@ class ProtocoloMateriaForm(ModelForm): [('assunto_ementa', 12)]) row4 = to_row( [('observacao', 12)]) + row5 = to_row( + [('numero', 12)]) self.helper = FormHelper() self.helper.layout = Layout( Fieldset(_('Identificação da Matéria'), - row1, row2, row3, - row4, form_actions(label='Protocolar Matéria'))) + row1, + row2, + row3, + row4, + HTML(" "), + ), + Fieldset(_('Número do Protocolo (Apenas se quiser que a numeração comece' + ' a partir do número a ser informado)'), + row5, + HTML(" "), + form_actions(label=_('Protocolar Matéria'))) + ) super(ProtocoloMateriaForm, self).__init__( *args, **kwargs) diff --git a/sapl/protocoloadm/views.py b/sapl/protocoloadm/views.py index ee03daaff..2474bb919 100644 --- a/sapl/protocoloadm/views.py +++ b/sapl/protocoloadm/views.py @@ -304,7 +304,12 @@ class ProtocoloDocumentoView(PermissionRequiredMixin, protocolo.tipo_processo = '0' # TODO validar o significado protocolo.anulado = False - protocolo.numero = (numero['numero__max'] + 1) if numero['numero__max'] else 1 + if not protocolo.numero: + protocolo.numero = (numero['numero__max'] + 1) if numero['numero__max'] else 1 + if protocolo.numero < (numero['numero__max'] + 1): + msg = _('Número de protocolo deve ser maior que {}').format(numero['numero__max']) + messages.add_message(self.request, messages.ERROR, msg) + return self.render_to_response(self.get_context_data()) protocolo.ano = timezone.now().year protocolo.data = timezone.now() protocolo.hora = timezone.now().time() @@ -415,6 +420,7 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): 'pk': protocolo.pk}) def form_valid(self, form): + protocolo = form.save(commit=False) try: numeracao = sapl.base.models.AppConfig.objects.last( ).sequencia_numeracao @@ -443,10 +449,12 @@ class ProtocoloMateriaView(PermissionRequiredMixin, CreateView): if numeracao is None: numero['numero__max'] = 0 - protocolo = Protocolo() - - protocolo.numero = ( - numero['numero__max'] + 1) if numero['numero__max'] else 1 + if not protocolo.numero: + protocolo.numero = (numero['numero__max'] + 1) if numero['numero__max'] else 1 + if protocolo.numero < (numero['numero__max'] + 1): + msg = _('Número de protocolo deve ser maior que {}').format(numero['numero__max']) + messages.add_message(self.request, messages.ERROR, msg) + return self.render_to_response(self.get_context_data()) protocolo.ano = timezone.now().year protocolo.data = timezone.now().date() protocolo.hora = timezone.now().time() From 365ca0f3ddb40fc327bb9866c5e0c6b590ef8d23 Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Fri, 13 Apr 2018 12:42:08 -0300 Subject: [PATCH 3/5] #1858 - Trazer Sessao Legislativa Atual (#1860) * Fix #1858 * Fix #1858 * Update views.py --- sapl/sessao/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index 01993f130..54d1fa21e 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -653,11 +653,15 @@ class SessaoCrud(Crud): def get_initial(self): legislatura = Legislatura.objects.order_by('-data_inicio').first() + if legislatura: return { 'legislatura': legislatura, - 'sessao_legislativa': legislatura.sessaoplenaria_set.first( - )} + 'sessao_legislativa': legislatura.sessaolegislativa_set.filter( + legislatura_id=legislatura.id, + data_inicio__year=timezone.now().year + ).first() + } else: msg = _('Cadastre alguma legislatura antes de adicionar ' + 'uma sessão plenária!') From ecabc8eb1312ddfe1ca4522e0b37160a75fdfa98 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Mon, 16 Apr 2018 10:27:56 -0300 Subject: [PATCH 4/5] Fix #1854 --- sapl/parlamentares/forms.py | 7 +++++++ sapl/static/styles/app.scss | 4 ++++ sapl/templates/parlamentares/layouts.yaml | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index acee7d7e1..e5b8d7d58 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -163,6 +163,13 @@ class ParlamentarCreateForm(ParlamentarForm): required=True, ) + class Meta(ParlamentarForm.Meta): + widgets = { + 'fotografia': forms.ClearableFileInput(), + 'biografia': forms.Textarea( + attrs={'id': 'texto-rico'}) + } + @transaction.atomic def save(self, commit=True): parlamentar = super(ParlamentarCreateForm, self).save(commit) diff --git a/sapl/static/styles/app.scss b/sapl/static/styles/app.scss index 262b3f45e..6a578d102 100644 --- a/sapl/static/styles/app.scss +++ b/sapl/static/styles/app.scss @@ -229,8 +229,12 @@ label { .form-control-static { padding-top: 0; min-height: auto; + img { + max-width: 100%; + } } + // #### pagination ######################################## .pagination { padding-top: 25px; diff --git a/sapl/templates/parlamentares/layouts.yaml b/sapl/templates/parlamentares/layouts.yaml index d31076100..ba7767cd2 100644 --- a/sapl/templates/parlamentares/layouts.yaml +++ b/sapl/templates/parlamentares/layouts.yaml @@ -42,7 +42,7 @@ Parlamentar: - municipio_residencia uf_residencia - telefone_residencia fax_residencia - locais_atuacao - - fotografia + - fotografia:5 - biografia ParlamentarUpdate: From 5593435d73a33e1c0f35cc308b9c6055383f9912 Mon Sep 17 00:00:00 2001 From: Talitha Pumar Date: Mon, 16 Apr 2018 11:30:59 -0300 Subject: [PATCH 5/5] Fix #1838 (#1847) --- sapl/relatorios/templates/pdf_etiqueta_protocolo_gerar.py | 6 +++++- sapl/relatorios/views.py | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sapl/relatorios/templates/pdf_etiqueta_protocolo_gerar.py b/sapl/relatorios/templates/pdf_etiqueta_protocolo_gerar.py index 142065450..38057791f 100755 --- a/sapl/relatorios/templates/pdf_etiqueta_protocolo_gerar.py +++ b/sapl/relatorios/templates/pdf_etiqueta_protocolo_gerar.py @@ -96,7 +96,11 @@ def protocolos(lst_protocolos, dic_cabecalho): tmp_data += '\t\t' + \ dic['data'] + '\n' tmp_data += '\t\t' + \ - dic['natureza'] + '\n' + dic['natureza'] + if dic['ident_processo']: + tmp_data += ' - ' + dic['ident_processo'] + '\n' + else: + tmp_data += '\n' tmp_data += '\t\n' return tmp_data diff --git a/sapl/relatorios/views.py b/sapl/relatorios/views.py index 00f33e44e..517e23229 100644 --- a/sapl/relatorios/views.py +++ b/sapl/relatorios/views.py @@ -955,10 +955,7 @@ def get_etiqueta_protocolos(prots): if p.tipo_processo == 0: dic['natureza'] = 'Administrativo' if p.tipo_processo == 1: - if dic['num_materia']: - dic['natureza'] = dic['num_materia'] - else: - dic['natureza'] = 'Legislativo' + dic['natureza'] = 'Legislativo' dic['num_documento'] = '' for documento in DocumentoAdministrativo.objects.filter(