diff --git a/sapl/compilacao/migrations/0002_auto_20170825_1108.py b/sapl/compilacao/migrations/0002_auto_20170825_1108.py new file mode 100644 index 000000000..e73b909a8 --- /dev/null +++ b/sapl/compilacao/migrations/0002_auto_20170825_1108.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2017-08-25 11:08 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='tipotextoarticulado', + name='content_type', + field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.ContentType', verbose_name='Modelo Integrado'), + ), + ] diff --git a/sapl/compilacao/migrations/0003_auto_20170825_1136.py b/sapl/compilacao/migrations/0003_auto_20170825_1136.py new file mode 100644 index 000000000..9104f98da --- /dev/null +++ b/sapl/compilacao/migrations/0003_auto_20170825_1136.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2017-08-25 11:36 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('compilacao', '0002_auto_20170825_1108'), + ] + + operations = [ + migrations.AlterField( + model_name='tipotextoarticulado', + name='content_type', + field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.ContentType', verbose_name='Modelo Integrado'), + ), + migrations.AlterField( + model_name='tipotextoarticulado', + name='participacao_social', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], default=False, verbose_name='Participação Social'), + preserve_default=False, + ), + migrations.AlterField( + model_name='tipotextoarticulado', + name='publicacao_func', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], default=False, verbose_name='Histórico de Publicação'), + preserve_default=False, + ), + ] diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py index fa0581b70..1426c2908 100644 --- a/sapl/compilacao/models.py +++ b/sapl/compilacao/models.py @@ -1,6 +1,5 @@ from datetime import datetime -import reversion from django.contrib import messages from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType @@ -13,6 +12,7 @@ from django.template import defaultfilters from django.utils.decorators import classonlymethod from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ +import reversion from sapl.compilacao.utils import (get_integrations_view_names, int_to_letter, int_to_roman) @@ -111,18 +111,17 @@ class TipoTextoArticulado(models.Model): descricao = models.CharField(max_length=50, verbose_name=_('Descrição')) content_type = models.OneToOneField( ContentType, - null=True, default=None, - verbose_name=_('Modelo Integrado')) - participacao_social = models.NullBooleanField( - default=False, blank=True, null=True, + on_delete=models.SET_NULL, + verbose_name=_('Modelo Integrado')) + participacao_social = models.BooleanField( + blank=False, choices=YES_NO_CHOICES, verbose_name=_('Participação Social')) - publicacao_func = models.NullBooleanField( - default=False, - blank=True, null=True, + publicacao_func = models.BooleanField( choices=YES_NO_CHOICES, + blank=False, verbose_name=_('Histórico de Publicação')) perfis = models.ManyToManyField( diff --git a/sapl/compilacao/tests/test_tipo_texto_articulado_form.py b/sapl/compilacao/tests/test_tipo_texto_articulado_form.py index afb8111ce..bb35ef688 100644 --- a/sapl/compilacao/tests/test_tipo_texto_articulado_form.py +++ b/sapl/compilacao/tests/test_tipo_texto_articulado_form.py @@ -16,14 +16,13 @@ def test_valida_campos_obrigatorios_tipo_texto_articulado_form(): assert errors['sigla'] == [_('Este campo é obrigatório.')] assert errors['descricao'] == [_('Este campo é obrigatório.')] - assert errors['content_type'] == [_('Este campo é obrigatório.')] assert errors['participacao_social'] == [_('Este campo é obrigatório.')] assert errors['publicacao_func'] == [_('Este campo é obrigatório.')] - assert len(errors) == 5 + assert len(errors) == 4 -_content_types = choice_models_in_extenal_views()[1:] +_content_types = choice_models_in_extenal_views() @pytest.mark.parametrize('content_type', _content_types)