diff --git a/sapl/compilacao/forms.py b/sapl/compilacao/forms.py index 71d6ad7e5..222a86aed 100644 --- a/sapl/compilacao/forms.py +++ b/sapl/compilacao/forms.py @@ -3,7 +3,6 @@ from datetime import timedelta from crispy_forms.bootstrap import (Alert, FieldWithButtons, FormActions, InlineCheckboxes, InlineRadios, StrictButton) -from sapl.crispy_layout_mixin import SaplFormHelper from crispy_forms.layout import (HTML, Button, Column, Div, Field, Fieldset, Layout, Row, Submit) from django import forms @@ -23,10 +22,12 @@ 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 SaplFormHelper from sapl.crispy_layout_mixin import SaplFormLayout, to_column, to_row,\ form_actions from sapl.utils import YES_NO_CHOICES + error_messages = { 'required': _('Este campo é obrigatório'), 'invalid': _('URL inválida.') @@ -59,6 +60,13 @@ class TipoTaForm(ModelForm): widget=forms.RadioSelect(), required=True) + rodape_global = forms.CharField( + label=TipoTextoArticulado._meta.get_field( + 'rodape_global').verbose_name, + widget=forms.Textarea(attrs={'id': 'texto-rico'}), + required=False + ) + class Meta: model = TipoTextoArticulado fields = ['sigla', @@ -66,10 +74,12 @@ class TipoTaForm(ModelForm): 'content_type', 'participacao_social', 'publicacao_func', - 'perfis' + 'perfis', + 'rodape_global' ] - widgets = {'perfis': widgets.CheckboxSelectMultiple()} + widgets = {'perfis': widgets.CheckboxSelectMultiple(), + 'rodape_global': forms.Textarea} def __init__(self, *args, **kwargs): @@ -84,12 +94,18 @@ class TipoTaForm(ModelForm): ('perfis', 12), ]) + row3 = to_row([ + ('rodape_global', 12), + ]) + self.helper = SaplFormHelper() self.helper.layout = SaplFormLayout( Fieldset(_('Identificação Básica'), row1, css_class="col-md-12"), Fieldset(_('Funcionalidades'), - row2, css_class="col-md-12")) + row2, css_class="col-md-12"), + Fieldset(_('Nota de Rodapé Global'), + row3, css_class="col-md-12")) super(TipoTaForm, self).__init__(*args, **kwargs) diff --git a/sapl/compilacao/migrations/0011_tipotextoarticulado_rodape_global.py b/sapl/compilacao/migrations/0011_tipotextoarticulado_rodape_global.py new file mode 100644 index 000000000..f3b0e323b --- /dev/null +++ b/sapl/compilacao/migrations/0011_tipotextoarticulado_rodape_global.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.20 on 2019-03-26 18:59 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0010_auto_20181004_1939'), + ] + + operations = [ + migrations.AddField( + model_name='tipotextoarticulado', + name='rodape_global', + field=models.TextField(default='', help_text='A cada Tipo de Texto Articulado pode ser adicionado uma nota global de rodapé!', verbose_name='Rodapé Global'), + ), + ] diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py index f36e406f9..f64285aee 100644 --- a/sapl/compilacao/models.py +++ b/sapl/compilacao/models.py @@ -149,6 +149,13 @@ class TipoTextoArticulado(models.Model): em edição. """)) + rodape_global = models.TextField( + verbose_name=_('Rodapé Global'), + help_text=_('A cada Tipo de Texto Articulado pode ser adicionado ' + 'uma nota global de rodapé!'), + default='' + ) + class Meta: verbose_name = _('Tipo de Texto Articulado') verbose_name_plural = _('Tipos de Texto Articulados') diff --git a/sapl/templates/compilacao/layouts.yaml b/sapl/templates/compilacao/layouts.yaml index 20446ba19..a92c8627b 100644 --- a/sapl/templates/compilacao/layouts.yaml +++ b/sapl/templates/compilacao/layouts.yaml @@ -45,3 +45,4 @@ TipoTextoArticulado: {% trans 'Funcionalidaes' %}: - participacao_social publicacao_func - perfis + - rodape_global diff --git a/sapl/templates/compilacao/text_list.html b/sapl/templates/compilacao/text_list.html index 3e9468e24..4efd992a9 100644 --- a/sapl/templates/compilacao/text_list.html +++ b/sapl/templates/compilacao/text_list.html @@ -18,4 +18,7 @@ {% endblock %} {% include 'compilacao/text_list__embedded.html'%} + {{object.tipo_ta.rodape_global|dont_break_out}} + + {% endblock base_content %}