From 1f03796a668ca54f3ce601e86dc4cf75f84475ff Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Fri, 7 Apr 2017 12:13:10 -0300 Subject: [PATCH] Correct improperly Servico cascade deletion when Funcionario was removed --- .../migrations/0003_auto_20170407_1003.py | 27 +++++++++++++++++++ sigi/apps/servicos/models.py | 4 +-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 sigi/apps/servicos/migrations/0003_auto_20170407_1003.py diff --git a/sigi/apps/servicos/migrations/0003_auto_20170407_1003.py b/sigi/apps/servicos/migrations/0003_auto_20170407_1003.py new file mode 100644 index 0000000..26fa40f --- /dev/null +++ b/sigi/apps/servicos/migrations/0003_auto_20170407_1003.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('servicos', '0002_tiposervico_modo'), + ] + + operations = [ + migrations.AlterField( + model_name='servico', + name='contato_administrativo', + field=models.ForeignKey(related_name='contato_administrativo', on_delete=django.db.models.deletion.PROTECT, verbose_name='Contato administrativo', to='casas.Funcionario'), + preserve_default=True, + ), + migrations.AlterField( + model_name='servico', + name='contato_tecnico', + field=models.ForeignKey(related_name='contato_tecnico', on_delete=django.db.models.deletion.PROTECT, verbose_name='Contato t\xe9cnico', to='casas.Funcionario'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/servicos/models.py b/sigi/apps/servicos/models.py index 6a9cde7..02c228c 100644 --- a/sigi/apps/servicos/models.py +++ b/sigi/apps/servicos/models.py @@ -39,8 +39,8 @@ class TipoServico(models.Model): class Servico(models.Model): casa_legislativa = models.ForeignKey(CasaLegislativa, verbose_name=_(u'Casa Legislativa')) tipo_servico = models.ForeignKey(TipoServico, verbose_name=_(u'Tipo de serviço')) - contato_tecnico = models.ForeignKey(Funcionario, verbose_name=_(u'Contato técnico'), related_name='contato_tecnico') - contato_administrativo = models.ForeignKey(Funcionario, verbose_name=_(u'Contato administrativo'), related_name='contato_administrativo') + contato_tecnico = models.ForeignKey(Funcionario, verbose_name=_(u'Contato técnico'), related_name='contato_tecnico', on_delete=models.PROTECT) + contato_administrativo = models.ForeignKey(Funcionario, verbose_name=_(u'Contato administrativo'), related_name='contato_administrativo', on_delete=models.PROTECT) url = models.URLField(_(u'URL do serviço'), blank=True) hospedagem_interlegis = models.BooleanField(_(u'Hospedagem no Interlegis?'), default=False) nome_servidor = models.CharField(_(u'Hospedado em'), max_length=60, blank=True,