diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index f21121c32..9970400c3 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -184,7 +184,7 @@ class NormaJuridicaForm(ModelForm): class AnexoNormaJuridicaForm(ModelForm): class Meta: model = AnexoNormaJuridica - fields = ['norma', 'anexo_arquivo'] + fields = ['norma', 'anexo_arquivo', 'assunto_anexo'] widgets = { 'norma': forms.HiddenInput(), } @@ -205,6 +205,7 @@ class AnexoNormaJuridicaForm(ModelForm): anexo.ano = self.cleaned_data['norma'].ano anexo = super(AnexoNormaJuridicaForm, self).save(commit=True) anexo.norma = self.cleaned_data['norma'] + anexo.assunto_anexo = self.cleaned_data['assunto_anexo'] anexo.anexo_arquivo = self.cleaned_data['anexo_arquivo'] anexo.save() return anexo diff --git a/sapl/norma/migrations/0013_anexonormajuridica_assunto_anexo.py b/sapl/norma/migrations/0013_anexonormajuridica_assunto_anexo.py new file mode 100644 index 000000000..e2eb9f5a9 --- /dev/null +++ b/sapl/norma/migrations/0013_anexonormajuridica_assunto_anexo.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2018-09-03 09:21 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0012_anexonormajuridica'), + ] + + operations = [ + migrations.AddField( + model_name='anexonormajuridica', + name='assunto_anexo', + field=models.TextField(blank=True, default='', max_length=250, verbose_name='Assunto do Anexo'), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 5e34214a1..e4e3677b3 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -273,6 +273,12 @@ class AnexoNormaJuridica(models.Model): related_name='norma', on_delete=models.PROTECT, verbose_name=_('Norma Juridica')) + assunto_anexo = models.TextField( + blank = True, + default = "", + verbose_name=_('Assunto do Anexo'), + max_length=250 + ) anexo_arquivo = models.FileField( blank=True, null=True, diff --git a/sapl/norma/views.py b/sapl/norma/views.py index c4a171da2..2cb4455c9 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -87,7 +87,7 @@ class NormaPesquisaView(FilterView): context['title'] = _('Pesquisar Norma Jurídica') self.filterset.form.fields['o'].label = _('Ordenação') - + qs = self.object_list if 'o' in self.request.GET and not self.request.GET['o']: qs = qs.order_by('-ano', 'tipo', '-numero') @@ -117,7 +117,7 @@ class AnexoNormaJuridicaCrud(MasterDetailCrud): public = [RP_LIST, RP_DETAIL] class BaseMixin(MasterDetailCrud.BaseMixin): - list_field_names = ['id', 'anexo_arquivo'] + list_field_names = ['id', 'anexo_arquivo', 'assunto_anexo'] class CreateView(MasterDetailCrud.CreateView): form_class = AnexoNormaJuridicaForm @@ -136,6 +136,7 @@ class AnexoNormaJuridicaCrud(MasterDetailCrud): initial = super(UpdateView, self).get_initial() initial['norma'] = self.object.norma initial['anexo_arquivo'] = self.object.anexo_arquivo + initial['assunto_anexo'] = self.object.assunto_anexo initial['ano'] = self.object.ano return initial diff --git a/sapl/templates/norma/layouts.yaml b/sapl/templates/norma/layouts.yaml index 591faed38..0075317c1 100644 --- a/sapl/templates/norma/layouts.yaml +++ b/sapl/templates/norma/layouts.yaml @@ -27,6 +27,7 @@ NormaJuridica: AnexoNormaJuridica: {% trans 'Adicionar Anexos à Norma Jurídica' %}: - anexo_arquivo + - assunto_anexo - norma NormaJuridicaCreate: