diff --git a/sigi/apps/casas/migrations/0017_auto_20210416_0841.py b/sigi/apps/casas/migrations/0017_auto_20210416_0841.py new file mode 100644 index 0000000..7f6cc71 --- /dev/null +++ b/sigi/apps/casas/migrations/0017_auto_20210416_0841.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('casas', '0016_auto_20210407_1559'), + ] + + operations = [ + migrations.AlterField( + model_name='funcionario', + name='casa_legislativa', + field=models.ForeignKey(verbose_name='\xf3rg\xe3o', to='casas.Orgao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='funcionario', + name='municipio', + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='Municipio', blank=True, to='contatos.Municipio', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='orgao', + name='municipio', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Munic\xedpio', to='contatos.Municipio'), + preserve_default=True, + ), + migrations.AlterField( + model_name='orgao', + name='pesquisador', + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='Pesquisador', blank=True, to='servidores.Servidor', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='orgao', + name='tipo', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Tipo', to='casas.TipoOrgao'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index 38548fd..b9ce584 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -51,7 +51,11 @@ class Orgao(models.Model): # Guarda um campo para ser usado em buscas em caixa baixa e sem acento search_text = SearchField(field_names=['nome']) # search_text.projeto_filter = True - tipo = models.ForeignKey(TipoOrgao, verbose_name=_(u"Tipo")) + tipo = models.ForeignKey( + TipoOrgao, + on_delete=models.PROTECT, + verbose_name=_(u"Tipo") + ) cnpj = models.CharField(_(u"CNPJ"), max_length=32, blank=True) observacoes = models.TextField(_(u'observações'), blank=True) horario_funcionamento = models.CharField( @@ -84,6 +88,7 @@ class Orgao(models.Model): municipio = models.ForeignKey( 'contatos.Municipio', + on_delete=models.PROTECT, verbose_name=_(u'Município') ) # municipio.uf_filter = True @@ -108,6 +113,7 @@ class Orgao(models.Model): ) pesquisador = models.ForeignKey( Servidor, + on_delete=models.SET_NULL, verbose_name=_(u"Pesquisador"), null=True, blank=True @@ -350,7 +356,11 @@ class Funcionario(models.Model): ("F", _(u"Feminino")) ] - casa_legislativa = models.ForeignKey(Orgao) + casa_legislativa = models.ForeignKey( + Orgao, + on_delete=models.CASCADE, + verbose_name=_(u"órgão"), + ) nome = models.CharField(_(u'nome completo'), max_length=60, blank=False) # nome.alphabetic_filter = True sexo = models.CharField( @@ -375,6 +385,7 @@ class Funcionario(models.Model): endereco = models.CharField(_(u'Endereço'), max_length=100, blank=True) municipio = models.ForeignKey( Municipio, + on_delete=models.SET_NULL, verbose_name=_(u'Municipio'), null=True, blank=True, diff --git a/sigi/apps/contatos/migrations/0003_auto_20210416_0841.py b/sigi/apps/contatos/migrations/0003_auto_20210416_0841.py new file mode 100644 index 0000000..ac856f1 --- /dev/null +++ b/sigi/apps/contatos/migrations/0003_auto_20210416_0841.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('contatos', '0002_auto_20151104_0810'), + ] + + operations = [ + migrations.AlterField( + model_name='contato', + name='municipio', + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='munic\xedpio', blank=True, to='contatos.Municipio', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='endereco', + name='municipio', + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, verbose_name='munic\xedpio', blank=True, to='contatos.Municipio', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='municipio', + name='microrregiao', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Microrregi\xe3o', blank=True, to='contatos.Microrregiao', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='municipio', + name='uf', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='UF', to='contatos.UnidadeFederativa'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/contatos/models.py b/sigi/apps/contatos/models.py index 9b3becf..200095f 100644 --- a/sigi/apps/contatos/models.py +++ b/sigi/apps/contatos/models.py @@ -51,7 +51,11 @@ class Mesorregiao(models.Model): unique=True, help_text=_(u'Código da mesorregião segundo o IBGE') ) - uf = models.ForeignKey(UnidadeFederativa, verbose_name=_(u'UF')) + uf = models.ForeignKey( + UnidadeFederativa, + on_delete=models.CASCADE, + verbose_name=_(u'UF') + ) nome = models.CharField(_(u"Nome mesorregião"), max_length=100) # Campo de busca em caixa baixa sem acento search_text = SearchField(field_names=['nome']) @@ -62,7 +66,7 @@ class Mesorregiao(models.Model): def __unicode__(self): return self.nome - + class Microrregiao(models.Model): codigo_ibge = models.PositiveIntegerField( _(u'Código IBGE'), @@ -70,7 +74,10 @@ class Microrregiao(models.Model): unique=True, help_text=_(u'Código da microrregião segundo o IBGE') ) - mesorregiao = models.ForeignKey(Mesorregiao) + mesorregiao = models.ForeignKey( + Mesorregiao, + on_delete=models.CASCADE + ) nome = models.CharField(_(u"Nome microrregião"), max_length=100) # Campo de busca em caixa baixa sem acento search_text = SearchField(field_names=['nome']) @@ -92,8 +99,14 @@ class Municipio(models.Model): unique=True, help_text=_(u'Código do município segundo IBGE.') ) - - microrregiao = models.ForeignKey(Microrregiao, verbose_name=_(u'Microrregião'), blank=True, null=True) + + microrregiao = models.ForeignKey( + Microrregiao, + on_delete=models.PROTECT, + verbose_name=_(u'Microrregião'), + blank=True, + null=True + ) # codio designado pelo Tribunal Superior Eleitoral codigo_tse = models.PositiveIntegerField( @@ -104,7 +117,11 @@ class Municipio(models.Model): ) nome = models.CharField(max_length=50) search_text = SearchField(field_names=[_(u'nome'), _(u'uf')]) - uf = models.ForeignKey(UnidadeFederativa, verbose_name=_(u'UF')) + uf = models.ForeignKey( + UnidadeFederativa, + on_delete=models.PROTECT, + verbose_name=_(u'UF') + ) # verdadeiro se o município é capital do estado is_capital = models.BooleanField(_(u'capital'), default=False) populacao = models.PositiveIntegerField(_(u'população')) @@ -200,6 +217,7 @@ class Contato(models.Model): municipio = models.ForeignKey( Municipio, + on_delete=models.SET_NULL, verbose_name=_(u'município'), blank=True, null=True, @@ -291,6 +309,7 @@ class Endereco(models.Model): municipio = models.ForeignKey( Municipio, + on_delete=models.SET_NULL, verbose_name=_(u'município'), blank=True, null=True, diff --git a/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py b/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py new file mode 100644 index 0000000..3698399 --- /dev/null +++ b/sigi/apps/convenios/migrations/0006_auto_20210416_0841.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('convenios', '0005_auto_20210409_0842'), + ] + + operations = [ + migrations.AlterField( + model_name='convenio', + name='casa_legislativa', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='\xf3rg\xe3o conveniado', to='casas.Orgao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='convenio', + name='projeto', + field=models.ForeignKey(to='convenios.Projeto', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='tramitacao', + name='unid_admin', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Unidade Administrativa', to='convenios.UnidadeAdministrativa'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index 9bafc84..2d5e998 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -42,11 +42,15 @@ class Convenio(models.Model): """ casa_legislativa = models.ForeignKey( 'casas.Orgao', + on_delete=models.PROTECT, verbose_name=_(u'órgão conveniado') ) # campo de busca em caixa baixa e sem acentos search_text = SearchField(field_names=['casa_legislativa']) - projeto = models.ForeignKey(_(u'Projeto')) + projeto = models.ForeignKey( + Projeto, + on_delete=models.PROTECT, + ) # numero designado pelo Senado Federal para o convênio num_processo_sf = models.CharField( _(u'número do processo SF (Senado Federal)'), @@ -227,8 +231,15 @@ class EquipamentoPrevisto(models.Model): disponibilizados para as Casas Legislativas (foi usado na prmeira etapa do programa) """ - convenio = models.ForeignKey(Convenio, verbose_name=_(u'convênio')) - equipamento = models.ForeignKey('inventario.Equipamento') + convenio = models.ForeignKey( + Convenio, + on_delete=models.CASCADE, + verbose_name=_(u'convênio') + ) + equipamento = models.ForeignKey( + 'inventario.Equipamento', + on_delete=models.CASCADE + ) quantidade = models.PositiveSmallIntegerField(default=1) class Meta: @@ -244,7 +255,11 @@ class Anexo(models.Model): """ Modelo para giardar os documentos gerados no processo de convênio """ - convenio = models.ForeignKey(Convenio, verbose_name=_(u'convênio')) + convenio = models.ForeignKey( + Convenio, + on_delete=models.CASCADE, + verbose_name=_(u'convênio') + ) # caminho no sistema para o documento anexo arquivo = models.FileField(upload_to='apps/convenios/anexo/arquivo', max_length=500) descricao = models.CharField(_(u'descrição'), max_length='70') @@ -278,8 +293,16 @@ class Tramitacao(models.Model): """ Modelo para registrar as vias do processo de convênio e a Unidade responsável pelo tramite (ex. colher assinaturas do secretário do senado) """ - convenio = models.ForeignKey(Convenio, verbose_name=_(u'convênio')) - unid_admin = models.ForeignKey(UnidadeAdministrativa, verbose_name=_(u'Unidade Administrativa')) + convenio = models.ForeignKey( + Convenio, + on_delete=models.CASCADE, + verbose_name=_(u'convênio') + ) + unid_admin = models.ForeignKey( + UnidadeAdministrativa, + on_delete=models.PROTECT, + verbose_name=_(u'Unidade Administrativa') + ) data = models.DateField() observacao = models.CharField( _(u'observação'), diff --git a/sigi/apps/diagnosticos/migrations/0005_auto_20210416_0841.py b/sigi/apps/diagnosticos/migrations/0005_auto_20210416_0841.py new file mode 100644 index 0000000..ec1a081 --- /dev/null +++ b/sigi/apps/diagnosticos/migrations/0005_auto_20210416_0841.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('diagnosticos', '0004_auto_20210406_1945'), + ] + + operations = [ + migrations.AlterField( + model_name='diagnostico', + name='casa_legislativa', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Casa Legislativa', to='casas.Orgao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='diagnostico', + name='responsavel', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='respons\xe1vel', to='servidores.Servidor'), + preserve_default=True, + ), + migrations.AlterField( + model_name='equipe', + name='membro', + field=models.ForeignKey(to='servidores.Servidor', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='escolha', + name='schema_to_open', + field=models.ForeignKey(related_name='abre_por', on_delete=django.db.models.deletion.SET_NULL, verbose_name='pergunta para abrir', blank=True, to='diagnosticos.Pergunta', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='resposta', + name='choice', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='escolha', blank=True, to='diagnosticos.Escolha', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='resposta', + name='schema', + field=models.ForeignKey(related_name='attrs', on_delete=django.db.models.deletion.PROTECT, verbose_name='pergunta', to='diagnosticos.Pergunta'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/diagnosticos/models.py b/sigi/apps/diagnosticos/models.py index bf67c28..44fc90c 100644 --- a/sigi/apps/diagnosticos/models.py +++ b/sigi/apps/diagnosticos/models.py @@ -15,7 +15,9 @@ class Diagnostico(BaseEntity): """ casa_legislativa = models.ForeignKey( 'casas.Orgao', - verbose_name=_(u'Casa Legislativa')) + on_delete=models.PROTECT, + verbose_name=_(u'Casa Legislativa') + ) # campo de busca em caixa baixa e sem acento search_text = SearchField(field_names=['casa_legislativa']) @@ -38,8 +40,11 @@ class Diagnostico(BaseEntity): blank=True, ) - responsavel = models.ForeignKey('servidores.Servidor', - verbose_name=_(u'responsável')) + responsavel = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.PROTECT, + verbose_name=_(u'responsável') + ) class Meta: verbose_name, verbose_name_plural = _(u'diagnóstico'), _(u'diagnósticos') @@ -156,7 +161,11 @@ class Pergunta(BaseSchema): Uma pergunta tem o nome e o tipo da resposta """ - categoria = models.ForeignKey(Categoria, related_name='perguntas') + categoria = models.ForeignKey( + Categoria, + on_delete=models.CASCADE, + related_name='perguntas' + ) def group_choices(self): from django.db import connection, transaction @@ -196,10 +205,20 @@ class Escolha(BaseChoice): """ Perguntas de multiplas escolhas tem as opções cadastradas neste modelo """ - schema = models.ForeignKey(Pergunta, - related_name='choices', verbose_name=_(u'pergunta')) - schema_to_open = models.ForeignKey(Pergunta, related_name='abre_por', - verbose_name=_(u'pergunta para abrir'), blank=True, null=True) + schema = models.ForeignKey( + Pergunta, + on_delete=models.CASCADE, + related_name='choices', + verbose_name=_(u'pergunta') + ) + schema_to_open = models.ForeignKey( + Pergunta, + on_delete=models.SET_NULL, + related_name='abre_por', + verbose_name=_(u'pergunta para abrir'), + blank=True, + null=True + ) ordem = models.PositiveIntegerField(blank=True, null=True) class Meta: @@ -212,10 +231,19 @@ class Resposta(BaseAttribute): """ Modelo para guardar as respostas das perguntas de um diagnosico """ - schema = models.ForeignKey(Pergunta, related_name='attrs', - verbose_name=_(u'pergunta')) - choice = models.ForeignKey(Escolha, verbose_name=_(u'escolha'), - blank=True, null=True) + schema = models.ForeignKey( + Pergunta, + on_delete=models.PROTECT, + related_name='attrs', + verbose_name=_(u'pergunta') + ) + choice = models.ForeignKey( + Escolha, + on_delete=models.PROTECT, + verbose_name=_(u'escolha'), + blank=True, + null=True + ) class Meta: verbose_name, verbose_name_plural = _(u'resposta'), _(u'respostas') @@ -225,8 +253,11 @@ class Equipe(models.Model): """ Modelo que representa a equipe de um diagnóstico """ - diagnostico = models.ForeignKey(Diagnostico) - membro = models.ForeignKey('servidores.Servidor') + diagnostico = models.ForeignKey(Diagnostico, on_delete=models.CASCADE) + membro = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.PROTECT + ) class Meta: verbose_name, verbose_name_plural = _(u'equipe'), _(u'equipe') @@ -240,7 +271,11 @@ class Anexo(models.Model): """ Modelo para representar os documentos levantados no processo de diagnóstico. Podem ser fotos, contratos, etc. """ - diagnostico = models.ForeignKey(Diagnostico, verbose_name=u'diagnóstico') + diagnostico = models.ForeignKey( + Diagnostico, + on_delete=models.CASCADE, + verbose_name=u'diagnóstico' + ) arquivo = models.FileField(upload_to='apps/diagnostico/anexo/arquivo', max_length=500) descricao = models.CharField(_(u'descrição'), max_length='70') data_pub = models.DateTimeField(_(u'data da publicação do anexo'), diff --git a/sigi/apps/eventos/migrations/0006_auto_20210416_0841.py b/sigi/apps/eventos/migrations/0006_auto_20210416_0841.py new file mode 100644 index 0000000..5779175 --- /dev/null +++ b/sigi/apps/eventos/migrations/0006_auto_20210416_0841.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('eventos', '0005_auto_20210406_1945'), + ] + + operations = [ + migrations.AlterField( + model_name='convite', + name='casa', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Casa convidada', to='casas.Orgao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='convite', + name='servidor', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Servidor que convidou', to='servidores.Servidor'), + preserve_default=True, + ), + migrations.AlterField( + model_name='equipe', + name='funcao', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Fun\xe7\xe3o na equipe', to='eventos.Funcao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='equipe', + name='membro', + field=models.ForeignKey(related_name='equipe_evento', on_delete=django.db.models.deletion.PROTECT, to='servidores.Servidor'), + preserve_default=True, + ), + migrations.AlterField( + model_name='evento', + name='casa_anfitria', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Casa anfitri\xe3', blank=True, to='casas.Orgao', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='evento', + name='municipio', + field=models.ForeignKey(to='contatos.Municipio', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='evento', + name='tipo_evento', + field=models.ForeignKey(to='eventos.TipoEvento', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + ] diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index b678a62..8fc11c2 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -27,15 +27,26 @@ class Evento(models.Model): ('C', _(u"Cancelado")) ) - tipo_evento = models.ForeignKey(TipoEvento) + tipo_evento = models.ForeignKey( + TipoEvento, + on_delete=models.PROTECT, + ) nome = models.CharField(_(u"Nome do evento"), max_length=100) descricao = models.TextField(_(u"Descrição do evento")) solicitante = models.CharField(_(u"Solicitante"), max_length=100) data_inicio = models.DateField(_(u"Data de início")) data_termino = models.DateField(_(u"Data de término")) - casa_anfitria = models.ForeignKey(Orgao, verbose_name=_(u"Casa anfitriã"), blank=True, - null=True) - municipio = models.ForeignKey(Municipio) + casa_anfitria = models.ForeignKey( + Orgao, + on_delete=models.PROTECT, + verbose_name=_(u"Casa anfitriã"), + blank=True, + null=True + ) + municipio = models.ForeignKey( + Municipio, + on_delete=models.PROTECT + ) local = models.TextField(_(u"Local do evento"), blank=True) publico_alvo = models.TextField(_(u"Público alvo"), blank=True) status = models.CharField(_(u"Status"), max_length=1, choices=STATUS_CHOICES) @@ -73,9 +84,20 @@ class Funcao(models.Model): return self.nome class Equipe(models.Model): - evento = models.ForeignKey(Evento) - membro = models.ForeignKey(Servidor, related_name="equipe_evento") - funcao = models.ForeignKey(Funcao, verbose_name=_(u"Função na equipe")) + evento = models.ForeignKey( + Evento, + on_delete=models.CASCADE + ) + membro = models.ForeignKey( + Servidor, + on_delete=models.PROTECT, + related_name="equipe_evento" + ) + funcao = models.ForeignKey( + Funcao, + on_delete=models.PROTECT, + verbose_name=_(u"Função na equipe") + ) observacoes = models.TextField(_(u"Observações"), blank=True) class Meta: @@ -86,9 +108,20 @@ class Equipe(models.Model): return u"%s (%s)" % (unicode(self.membro), unicode(self.funcao),) class Convite(models.Model): - evento = models.ForeignKey(Evento) - casa = models.ForeignKey(Orgao, verbose_name=_(u"Casa convidada")) - servidor = models.ForeignKey(Servidor, verbose_name=_(u"Servidor que convidou")) + evento = models.ForeignKey( + Evento, + on_delete=models.CASCADE + ) + casa = models.ForeignKey( + Orgao, + on_delete=models.PROTECT, + verbose_name=_(u"Casa convidada") + ) + servidor = models.ForeignKey( + Servidor, + on_delete=models.PROTECT, + verbose_name=_(u"Servidor que convidou") + ) data_convite = models.DateField(_(u"Data do convite")) aceite = models.BooleanField(_("Aceitou o convite"), default=False) participou = models.BooleanField(_(u"Participou do evento"), default=False) diff --git a/sigi/apps/financeiro/models.py b/sigi/apps/financeiro/models.py index 44b7cae..e0e2061 100644 --- a/sigi/apps/financeiro/models.py +++ b/sigi/apps/financeiro/models.py @@ -6,7 +6,11 @@ from sigi.apps.convenios.models import Projeto class Desembolso(models.Model): - projeto = models.ForeignKey(Projeto, verbose_name=_(u'Projeto')) + projeto = models.ForeignKey( + Projeto, + on_delete=models.CASCADE, + verbose_name=_(u'Projeto') + ) descricao = models.CharField(_(u'Descrição da despesa'), max_length=100) data = models.DateField(_(u'Data do desembolso')) valor_reais = models.DecimalField(_(u'Valor em R$'), max_digits=18, decimal_places=2) diff --git a/sigi/apps/inventario/migrations/0003_auto_20210416_0841.py b/sigi/apps/inventario/migrations/0003_auto_20210416_0841.py new file mode 100644 index 0000000..07c7ee7 --- /dev/null +++ b/sigi/apps/inventario/migrations/0003_auto_20210416_0841.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('inventario', '0002_auto_20210406_1945'), + ] + + operations = [ + migrations.AlterField( + model_name='bem', + name='fornecedor', + field=models.ForeignKey(to='inventario.Fornecedor', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='equipamento', + name='fabricante', + field=models.ForeignKey(to='inventario.Fabricante', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='equipamento', + name='modelo', + field=models.ForeignKey(to='inventario.ModeloEquipamento', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='modeloequipamento', + name='tipo', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='tipo de equipamento', to='inventario.TipoEquipamento'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/inventario/models.py b/sigi/apps/inventario/models.py index cdb67cc..2018769 100644 --- a/sigi/apps/inventario/models.py +++ b/sigi/apps/inventario/models.py @@ -46,6 +46,7 @@ class TipoEquipamento(models.Model): class ModeloEquipamento(models.Model): tipo = models.ForeignKey( TipoEquipamento, + on_delete=models.PROTECT, verbose_name=_(u'tipo de equipamento') ) modelo = models.CharField(max_length=30) @@ -60,8 +61,14 @@ class ModeloEquipamento(models.Model): class Equipamento(models.Model): - fabricante = models.ForeignKey(Fabricante) - modelo = models.ForeignKey(ModeloEquipamento) + fabricante = models.ForeignKey( + Fabricante, + on_delete=models.PROTECT + ) + modelo = models.ForeignKey( + ModeloEquipamento, + on_delete=models.PROTECT + ) class Meta: unique_together = (('fabricante', 'modelo'),) @@ -72,9 +79,15 @@ class Equipamento(models.Model): class Bem(models.Model): - casa_legislativa = models.ForeignKey('casas.Orgao') - equipamento = models.ForeignKey(Equipamento) - fornecedor = models.ForeignKey(Fornecedor) + casa_legislativa = models.ForeignKey( + 'casas.Orgao', + on_delete=models.CASCADE + ) + equipamento = models.ForeignKey(Equipamento, on_delete=models.CASCADE) + fornecedor = models.ForeignKey( + Fornecedor, + on_delete=models.PROTECT + ) num_serie = models.CharField( _(u'número de série'), max_length=64, diff --git a/sigi/apps/metas/models.py b/sigi/apps/metas/models.py index e7d5a90..c267abf 100644 --- a/sigi/apps/metas/models.py +++ b/sigi/apps/metas/models.py @@ -18,7 +18,12 @@ class Meta(models.Model): ('COUNT_PDIR', _(u'Quantidade de planos diretores')), ('COUNT_CONV', _(u'Quantidade de casas conveniadas')), ) - projeto = models.ForeignKey(Projeto, verbose_name=_(u'Projeto'), help_text=_(u'Projeto ao qual a meta se refere')) + projeto = models.ForeignKey( + Projeto, + on_delete=models.CASCADE, + verbose_name=_(u'Projeto'), + help_text=_(u'Projeto ao qual a meta se refere') + ) titulo = models.CharField(_(u'Título'), max_length=40, help_text=_(u'Título da meta que aparecerá no dashboard')) descricao = models.TextField(_(u'Descrição')) data_inicio = models.DateField(_(u'Data inicial'), help_text=_(u'Início do período de cômputo da meta')) @@ -114,8 +119,16 @@ class PlanoDiretor(models.Model): ('E', _(u'Entregue')), ('I', _(u'Implantado')), ) - projeto = models.ForeignKey(Projeto, verbose_name=_(u'Projeto')) - casa_legislativa = models.ForeignKey(Orgao, verbose_name=_(u'Casa Legislativa')) + projeto = models.ForeignKey( + Projeto, + on_delete=models.CASCADE, + verbose_name=_(u'Projeto') + ) + casa_legislativa = models.ForeignKey( + Orgao, + on_delete=models.CASCADE, + verbose_name=_(u'Casa Legislativa') + ) casa_legislativa.casa_uf_filter = True status = models.CharField(_(u'Status'), max_length=1, choices=STATUS_CHOICE, default='E') data_entrega = models.DateField(_(u'Data de entrega'), blank=True, null=True) diff --git a/sigi/apps/ocorrencias/migrations/0004_auto_20210416_0841.py b/sigi/apps/ocorrencias/migrations/0004_auto_20210416_0841.py new file mode 100644 index 0000000..54ce623 --- /dev/null +++ b/sigi/apps/ocorrencias/migrations/0004_auto_20210416_0841.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('ocorrencias', '0003_auto_20210406_1945'), + ] + + operations = [ + migrations.AlterField( + model_name='categoria', + name='setor_responsavel', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Setor respons\xe1vel', to='servidores.Servico'), + preserve_default=True, + ), + migrations.AlterField( + model_name='comentario', + name='encaminhar_setor', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Encaminhar para setor', blank=True, to='servidores.Servico', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='comentario', + name='usuario', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Usu\xe1rio', to='servidores.Servidor'), + preserve_default=True, + ), + migrations.AlterField( + model_name='ocorrencia', + name='categoria', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Categoria', to='ocorrencias.Categoria'), + preserve_default=True, + ), + migrations.AlterField( + model_name='ocorrencia', + name='servidor_registro', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Servidor que registrou a ocorr\xeancia', to='servidores.Servidor'), + preserve_default=True, + ), + migrations.AlterField( + model_name='ocorrencia', + name='setor_responsavel', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Setor respons\xe1vel', to='servidores.Servico'), + preserve_default=True, + ), + migrations.AlterField( + model_name='ocorrencia', + name='tipo_contato', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Tipo de contato', to='ocorrencias.TipoContato'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/ocorrencias/models.py b/sigi/apps/ocorrencias/models.py index 0774147..873f731 100644 --- a/sigi/apps/ocorrencias/models.py +++ b/sigi/apps/ocorrencias/models.py @@ -9,7 +9,11 @@ from django.utils.safestring import mark_safe class Categoria(models.Model): nome = models.CharField(_(u"Categoria"), max_length=50) descricao = models.TextField(_(u'descrição'), blank=True, null=True) - setor_responsavel = models.ForeignKey('servidores.Servico', verbose_name=_(u"Setor responsável")) + setor_responsavel = models.ForeignKey( + 'servidores.Servico', + on_delete=models.PROTECT, + verbose_name=_(u"Setor responsável") + ) class Meta: verbose_name, verbose_name_plural = _(u'Categoria'), _(u'Categorias') @@ -51,13 +55,25 @@ class Ocorrencia(models.Model): (5, _(u'Baixíssimo')), ) - casa_legislativa = models.ForeignKey('casas.Orgao', verbose_name=_(u'Casa Legislativa')) + casa_legislativa = models.ForeignKey( + 'casas.Orgao', + on_delete=models.CASCADE, + verbose_name=_(u'Casa Legislativa') + ) casa_legislativa.convenio_uf_filter = True casa_legislativa.convenio_cl_tipo_filter = True data_criacao = models.DateField(_(u'Data de criação'), null=True, blank=True, auto_now_add=True) data_modificacao = models.DateField(_(u'Data de modificação'), null=True, blank=True, auto_now=True) - categoria = models.ForeignKey(Categoria, verbose_name=_(u'Categoria')) - tipo_contato = models.ForeignKey(TipoContato, verbose_name=_(u"Tipo de contato")) + categoria = models.ForeignKey( + Categoria, + on_delete=models.PROTECT, + verbose_name=_(u'Categoria') + ) + tipo_contato = models.ForeignKey( + TipoContato, + on_delete=models.PROTECT, + verbose_name=_(u"Tipo de contato") + ) assunto = models.CharField(_(u'Assunto'), max_length=200) assunto.grupo_filter = True status = models.IntegerField(_(u'Status'), choices=STATUS_CHOICES, default=1,) @@ -65,8 +81,16 @@ class Ocorrencia(models.Model): prioridade = models.IntegerField(_(u'Prioridade'), choices=PRIORITY_CHOICES, default=3, ) descricao = models.TextField(_(u'descrição'), blank=True,) resolucao = models.TextField(_(u'resolução'), blank=True,) - servidor_registro = models.ForeignKey('servidores.Servidor', verbose_name=_(u"Servidor que registrou a ocorrência")) - setor_responsavel = models.ForeignKey('servidores.Servico', verbose_name=_(u"Setor responsável")) + servidor_registro = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.PROTECT, + verbose_name=_(u"Servidor que registrou a ocorrência") + ) + setor_responsavel = models.ForeignKey( + 'servidores.Servico', + on_delete=models.PROTECT, + verbose_name=_(u"Setor responsável") + ) ticket = models.PositiveIntegerField(_(u'Número do ticket'), blank=True, null=True, help_text=_(u"Número do ticket no osTicket")) class Meta: @@ -85,12 +109,27 @@ class Ocorrencia(models.Model): return mark_safe(settings.OSTICKET_URL % self.ticket) class Comentario(models.Model): - ocorrencia = models.ForeignKey(Ocorrencia, verbose_name=_(u'Ocorrência'), related_name='comentarios') + ocorrencia = models.ForeignKey( + Ocorrencia, + on_delete=models.CASCADE, + verbose_name=_(u'Ocorrência'), + related_name='comentarios' + ) data_criacao = models.DateTimeField(_(u'Data de criação'), null=True, blank=True, auto_now_add=True) descricao = models.TextField(_(u'Descrição'), blank=True, null=True) - usuario = models.ForeignKey('servidores.Servidor', verbose_name=_(u'Usuário')) + usuario = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.PROTECT, + verbose_name=_(u'Usuário') + ) novo_status = models.IntegerField(_(u'Novo status'), choices=Ocorrencia.STATUS_CHOICES, blank=True, null=True) - encaminhar_setor = models.ForeignKey('servidores.Servico', verbose_name=_(u'Encaminhar para setor'), blank=True, null=True) + encaminhar_setor = models.ForeignKey( + 'servidores.Servico', + on_delete=models.PROTECT, + verbose_name=_(u'Encaminhar para setor'), + blank=True, + null=True + ) def save(self, *args, **kwargs): if self.encaminhar_setor and (self.encaminhar_setor != self.ocorrencia.setor_responsavel): @@ -103,7 +142,11 @@ class Comentario(models.Model): class Anexo(models.Model): - ocorrencia = models.ForeignKey(Ocorrencia, verbose_name=_(u'ocorrência')) + ocorrencia = models.ForeignKey( + Ocorrencia, + on_delete=models.CASCADE, + verbose_name=_(u'ocorrência') + ) arquivo = models.FileField(_(u'Arquivo anexado'), upload_to='apps/ocorrencia/anexo/arquivo', max_length=500) descricao = models.CharField(_(u'descrição do anexo'), max_length='70') data_pub = models.DateTimeField(_(u'data da publicação do anexo'), null=True, blank=True, auto_now_add=True) diff --git a/sigi/apps/parlamentares/migrations/0003_auto_20210416_0841.py b/sigi/apps/parlamentares/migrations/0003_auto_20210416_0841.py new file mode 100644 index 0000000..f7d418b --- /dev/null +++ b/sigi/apps/parlamentares/migrations/0003_auto_20210416_0841.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0002_auto_20210406_1945'), + ] + + operations = [ + migrations.AlterField( + model_name='mandato', + name='cargo', + field=models.ForeignKey(to='parlamentares.Cargo', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='membromesadiretora', + name='cargo', + field=models.ForeignKey(to='parlamentares.Cargo', on_delete=django.db.models.deletion.PROTECT), + preserve_default=True, + ), + migrations.AlterField( + model_name='sessaolegislativa', + name='mesa_diretora', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Mesa Diretora', to='parlamentares.MesaDiretora'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/parlamentares/models.py b/sigi/apps/parlamentares/models.py index 238b62e..f9c64fa 100644 --- a/sigi/apps/parlamentares/models.py +++ b/sigi/apps/parlamentares/models.py @@ -59,10 +59,13 @@ class Mandato(models.Model): ('T', _(u'Titular')), ('S', _(u'Suplente')), ) - parlamentar = models.ForeignKey(Parlamentar) - legislatura = models.ForeignKey('parlamentares.Legislatura') - partido = models.ForeignKey(Partido) - cargo = models.ForeignKey('parlamentares.Cargo') + parlamentar = models.ForeignKey(Parlamentar, on_delete=models.CASCADE) + legislatura = models.ForeignKey( + 'parlamentares.Legislatura', + on_delete=models.CASCADE + ) + partido = models.ForeignKey(Partido, on_delete=models.CASCADE) + cargo = models.ForeignKey('parlamentares.Cargo', on_delete=models.PROTECT) inicio_mandato = models.DateField(_(u'início de mandato')) fim_mandato = models.DateField(_(u'fim de mandato')) is_afastado = models.BooleanField( @@ -82,7 +85,7 @@ class Mandato(models.Model): class Legislatura(models.Model): - casa_legislativa = models.ForeignKey(Orgao) + casa_legislativa = models.ForeignKey(Orgao, on_delete=models.CASCADE) numero = models.PositiveSmallIntegerField(_(u'número legislatura')) data_inicio = models.DateField(_(u'início')) data_fim = models.DateField(_(u'fim')) @@ -106,7 +109,7 @@ class Legislatura(models.Model): class Coligacao(models.Model): nome = models.CharField(max_length=50) - legislatura = models.ForeignKey(Legislatura) + legislatura = models.ForeignKey(Legislatura, on_delete=models.CASCADE) numero_votos = models.PositiveIntegerField( _(u'número de votos'), blank=True, @@ -123,8 +126,15 @@ class Coligacao(models.Model): class ComposicaoColigacao(models.Model): - coligacao = models.ForeignKey(Coligacao, verbose_name=_(u'coligação')) - partido = models.ForeignKey('parlamentares.Partido') + coligacao = models.ForeignKey( + Coligacao, + on_delete=models.CASCADE, + verbose_name=_(u'coligação') + ) + partido = models.ForeignKey( + 'parlamentares.Partido', + on_delete=models.CASCADE + ) class Meta: verbose_name = _(u'composição da coligação') @@ -142,9 +152,10 @@ class SessaoLegislativa(models.Model): numero = models.PositiveSmallIntegerField(_(u'número da sessão'), unique=True) mesa_diretora = models.ForeignKey( 'MesaDiretora', + on_delete=models.PROTECT, verbose_name=_(u'Mesa Diretora') ) - legislatura = models.ForeignKey(Legislatura) + legislatura = models.ForeignKey(Legislatura, on_delete=models.CASCADE) tipo = models.CharField( max_length=1, choices=SESSAO_CHOICES, @@ -175,6 +186,7 @@ class SessaoLegislativa(models.Model): class MesaDiretora(models.Model): casa_legislativa = models.ForeignKey( 'casas.Orgao', + on_delete=models.CASCADE, verbose_name=_(u'Casa Legislativa') ) @@ -197,9 +209,12 @@ class Cargo(models.Model): class MembroMesaDiretora(models.Model): - parlamentar = models.ForeignKey('parlamentares.Parlamentar') - cargo = models.ForeignKey(Cargo) - mesa_diretora = models.ForeignKey(MesaDiretora) + parlamentar = models.ForeignKey( + 'parlamentares.Parlamentar', + on_delete=models.CASCADE + ) + cargo = models.ForeignKey(Cargo, on_delete=models.PROTECT) + mesa_diretora = models.ForeignKey(MesaDiretora, on_delete=models.CASCADE) class Meta: ordering = ('parlamentar',) diff --git a/sigi/apps/servicos/migrations/0007_auto_20210416_0841.py b/sigi/apps/servicos/migrations/0007_auto_20210416_0841.py new file mode 100644 index 0000000..4480c55 --- /dev/null +++ b/sigi/apps/servicos/migrations/0007_auto_20210416_0841.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', '0006_casaatendida'), + ] + + operations = [ + migrations.AlterField( + model_name='servico', + name='casa_legislativa', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Casa Legislativa', to='casas.Orgao'), + preserve_default=True, + ), + migrations.AlterField( + model_name='servico', + name='tipo_servico', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, verbose_name='Tipo de servi\xe7o', to='servicos.TipoServico'), + preserve_default=True, + ), + ] diff --git a/sigi/apps/servicos/models.py b/sigi/apps/servicos/models.py index 74b344e..3fe7d36 100644 --- a/sigi/apps/servicos/models.py +++ b/sigi/apps/servicos/models.py @@ -37,10 +37,28 @@ class TipoServico(models.Model): class Servico(models.Model): - casa_legislativa = models.ForeignKey(Orgao, 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', on_delete=models.PROTECT) - contato_administrativo = models.ForeignKey(Funcionario, verbose_name=_(u'Contato administrativo'), related_name='contato_administrativo', on_delete=models.PROTECT) + casa_legislativa = models.ForeignKey( + Orgao, + on_delete=models.PROTECT, + verbose_name=_(u'Casa Legislativa') + ) + tipo_servico = models.ForeignKey( + TipoServico, + on_delete=models.PROTECT, + verbose_name=_(u'Tipo de serviço') + ) + contato_tecnico = models.ForeignKey( + Funcionario, + on_delete=models.PROTECT, + verbose_name=_(u'Contato técnico'), + related_name='contato_tecnico' + ) + contato_administrativo = models.ForeignKey( + Funcionario, + on_delete=models.PROTECT, + verbose_name=_(u'Contato administrativo'), + related_name='contato_administrativo' + ) 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, @@ -162,7 +180,11 @@ class Servico(models.Model): class LogServico(models.Model): - servico = models.ForeignKey(Servico, verbose_name=_(u'Serviço')) + servico = models.ForeignKey( + Servico, + on_delete=models.CASCADE, + verbose_name=_(u'Serviço') + ) descricao = models.CharField(_(u'Breve descrição da ação'), max_length=60) data = models.DateField(_(u'Data da ação'), default=date.today) log = models.TextField(_(u'Log da ação')) @@ -202,8 +224,8 @@ class CasaManifesta(models.Model): class ServicoManifesto(models.Model): - casa_manifesta = models.ForeignKey(CasaManifesta) - servico = models.ForeignKey(TipoServico) + casa_manifesta = models.ForeignKey(CasaManifesta, on_delete=models.CASCADE) + servico = models.ForeignKey(TipoServico, on_delete=models.CASCADE) url = models.URLField(blank=True) hospedagem_interlegis = models.BooleanField(_(u'Hospedagem no Interlegis?'), default=False) diff --git a/sigi/apps/servidores/migrations/0002_auto_20210416_0841.py b/sigi/apps/servidores/migrations/0002_auto_20210416_0841.py new file mode 100644 index 0000000..a75cb70 --- /dev/null +++ b/sigi/apps/servidores/migrations/0002_auto_20210416_0841.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('servidores', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='servico', + name='responsavel', + field=models.ForeignKey(related_name='chefe', on_delete=django.db.models.deletion.SET_NULL, to='servidores.Servidor', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='servidor', + name='servico', + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, to='servidores.Servico', null=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='subsecretaria', + name='responsavel', + field=models.ForeignKey(related_name='diretor', on_delete=django.db.models.deletion.SET_NULL, to='servidores.Servidor', null=True), + preserve_default=True, + ), + ] diff --git a/sigi/apps/servidores/models.py b/sigi/apps/servidores/models.py index 0b8e8f6..1e00e92 100644 --- a/sigi/apps/servidores/models.py +++ b/sigi/apps/servidores/models.py @@ -14,7 +14,12 @@ class Subsecretaria(models.Model): nome = models.CharField(max_length=250, null=True) sigla = models.CharField(max_length=10, null=True) # servidor responsavel por dirigir a Subsecretaria - responsavel = models.ForeignKey('servidores.Servidor', related_name='diretor', null=True) + responsavel = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.SET_NULL, + related_name='diretor', + null=True + ) class Meta: ordering = ('nome',) @@ -30,9 +35,18 @@ class Servico(models.Model): nome = models.CharField(_(u'Setor'), max_length=250, null=True) sigla = models.CharField(max_length=10, null=True) - subsecretaria = models.ForeignKey(Subsecretaria, null=True) + subsecretaria = models.ForeignKey( + Subsecretaria, + on_delete=models.CASCADE, + null=True + ) # servidor responsavel por chefiar o serviço - responsavel = models.ForeignKey('servidores.Servidor', related_name='chefe', null=True) + responsavel = models.ForeignKey( + 'servidores.Servidor', + on_delete=models.SET_NULL, + related_name='chefe', + null=True + ) class Meta: ordering = ('nome',) @@ -63,7 +77,7 @@ class Servidor(models.Model): ) # usuario responsavel pela autenticação do servidor no sistema - user = models.ForeignKey(User, unique=True) + user = models.ForeignKey(User, on_delete=models.CASCADE, unique=True) nome_completo = models.CharField(max_length=128) apelido = models.CharField(max_length=50, blank=True) # caminho no sistema para arquivo com a imagem @@ -86,7 +100,12 @@ class Servidor(models.Model): blank=True, null=True, ) - servico = models.ForeignKey('servidores.Servico', blank=True, null=True) + servico = models.ForeignKey( + 'servidores.Servico', + on_delete=models.SET_NULL, + blank=True, + null=True + ) matricula = models.CharField(u'matrícula', max_length=25, blank=True, null=True) turno = models.CharField( max_length=1, @@ -170,7 +189,7 @@ class Funcao(models.Model): """ Modelo para guardar o histórico de funções dos servidores no Interlegis """ - servidor = models.ForeignKey(Servidor) + servidor = models.ForeignKey(Servidor, on_delete=models.CASCADE) funcao = models.CharField(max_length=250, null=True) cargo = models.CharField(max_length=250, null=True) inicio_funcao = models.DateField(u'início da função', null=True) @@ -195,7 +214,7 @@ class Licenca(models.Model): """ Modelo que representa as licenças tiradas pelos servidores """ - servidor = models.ForeignKey(Servidor) + servidor = models.ForeignKey(Servidor, on_delete=models.CASCADE) inicio_licenca = models.DateField(u'início da licença') fim_licenca = models.DateField(u'fim da licença') obs = models.TextField(u'observação', blank=True, null=True) @@ -217,7 +236,7 @@ class Ferias(models.Model): """ Modelo que representa as férias tiradas pelos servidores """ - servidor = models.ForeignKey(Servidor) + servidor = models.ForeignKey(Servidor, on_delete=models.CASCADE) inicio_ferias = models.DateField(u'início das férias') fim_ferias = models.DateField(u'fim das férias') obs = models.TextField(u'observação', blank=True, null=True)