From 29d19486983f94aca52df237d208ff57810914a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Cantu=C3=A1ria?= Date: Mon, 15 Apr 2019 16:51:08 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20script=20para=20remover=20protocolos?= =?UTF-8?q?=20inexistentes=20em=20mat=C3=A9rias=20(#2708)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/remove_protocolos_inexistentes_materias.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 scripts/remove_protocolos_inexistentes_materias.py diff --git a/scripts/remove_protocolos_inexistentes_materias.py b/scripts/remove_protocolos_inexistentes_materias.py new file mode 100644 index 000000000..b8881b1c9 --- /dev/null +++ b/scripts/remove_protocolos_inexistentes_materias.py @@ -0,0 +1,13 @@ +from sapl.materia.models import MateriaLegislativa +from sapl.protocoloadm.models import Protocolo + + +def main(): + for materia in MateriaLegislativa.objects.filter(numero_protocolo__isnull=False): + if not Protocolo.objects.filter(ano=materia.ano, numero=materia.numero_protocolo).exists(): + materia.numero_protocolo = None + materia.save() + + +if __name__ == '__main__': + main()