From f1cdb1ce527fd6e026b6f82855f4ed920301fd7c Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Sat, 1 Sep 2018 17:13:57 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20cria=C3=A7=C3=A3o=20de=20autor=20ao?= =?UTF-8?q?=20ressucitar=20deps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/scripts/.flake8 | 3 +++ sapl/legacy/scripts/ressucita_dependencias.py | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 sapl/legacy/scripts/.flake8 diff --git a/sapl/legacy/scripts/.flake8 b/sapl/legacy/scripts/.flake8 new file mode 100644 index 000000000..977657542 --- /dev/null +++ b/sapl/legacy/scripts/.flake8 @@ -0,0 +1,3 @@ +[flake8] +ignore = E501 + diff --git a/sapl/legacy/scripts/ressucita_dependencias.py b/sapl/legacy/scripts/ressucita_dependencias.py index daa4ed126..7f51de9f7 100644 --- a/sapl/legacy/scripts/ressucita_dependencias.py +++ b/sapl/legacy/scripts/ressucita_dependencias.py @@ -221,6 +221,13 @@ def get_dependencias_a_ressucitar(slug): return preambulo, desexcluir, criar +# deve ser idempotente pois é usada na criação de autor +# por isso o ON DUPLICATE KEY UPDATE +SQL_INSERT_TIPO_AUTOR = ''' + insert into tipo_autor (tip_autor, des_tipo_autor, ind_excluido) + values ({}, "DESCONHECIDO", 0) ON DUPLICATE KEY UPDATE ind_excluido = 0; + ''' + SQLS_CRIACAO = [ ('tipo_proposicao', ''' insert into tipo_materia_legislativa ( @@ -239,14 +246,18 @@ SQLS_CRIACAO = [ tip_resultado_votacao, nom_resultado, ind_excluido) values ({}, "DESCONHECIDO", 0); '''), - ('tipo_autor', ''' - insert into tipo_autor (tip_autor, des_tipo_autor, ind_excluido) - values ({}, "DESCONHECIDO", 0); - '''), + ('tipo_autor', SQL_INSERT_TIPO_AUTOR), ('unidade_tramitacao', ''' - insert into unidade_tramitacao (cod_unid_tramitacao, cod_comissao, cod_orgao, cod_parlamentar, ind_excluido) + insert into unidade_tramitacao ( + cod_unid_tramitacao, cod_comissao, cod_orgao, cod_parlamentar, ind_excluido) values ({}, NULL, NULL, NULL, 0); '''), + ('autor', SQL_INSERT_TIPO_AUTOR.format(0) + ''' + insert into autor ( + cod_autor, cod_partido, cod_comissao, cod_parlamentar, tip_autor, + nom_autor, des_cargo, col_username, ind_excluido) + values ({}, 0, 0, 0, 0, "DESCONHECIDO", "DESCONHECIDO", NULL, 0); + ''') ] SQLS_CRIACAO = {k: (dedent(sql.strip()), extras) for k, sql, *extras in SQLS_CRIACAO}