From 331a82ed1d0b4e9c0e26526540e90bb9e2143cad Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 28 Aug 2018 10:41:26 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20slug=20=C3=A0=20gera=C3=A7=C3=A3o=20?= =?UTF-8?q?de=20links=20de=20ressucitados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/scripts/ressucita_dependencias.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sapl/legacy/scripts/ressucita_dependencias.py b/sapl/legacy/scripts/ressucita_dependencias.py index 03ba371bf..1564879da 100644 --- a/sapl/legacy/scripts/ressucita_dependencias.py +++ b/sapl/legacy/scripts/ressucita_dependencias.py @@ -265,25 +265,26 @@ ind_excluido) values ({}, {}, 0, "O", '''.format(valor, num_legislatura) -def get_link(tabela_alvo, valor): - return '{}/{}'.format(urls[tabela_alvo], valor) +def get_link(tabela_alvo, valor, slug): + url_base = get_url(slug) + return 'http://{}{}/{}'.format(url_base, urls[tabela_alvo], valor) -def get_sql_desexcluir(tabela_alvo, campo, valor): +def get_sql_desexcluir(tabela_alvo, campo, valor, slug): sql = 'update {} set ind_excluido = 0 where {} = {};'.format( tabela_alvo, campo, valor) - return sql, [get_link(tabela_alvo, valor)] + return sql, [get_link(tabela_alvo, valor, slug)] -def get_sql_criar(tabela_alvo, campo, valor): +def get_sql_criar(tabela_alvo, campo, valor, slug): if tabela_alvo == 'sessao_legislativa': sql = criar_sessao_legislativa(campo, valor) else: sql, extras = SQLS_CRIACAO[tabela_alvo] sql = sql.format(valor) - links = [get_link(tabela_alvo, valor)] + links = [get_link(tabela_alvo, valor, slug)] for tabela_extra, valor_extra in extras: - links.insert(0, get_link(tabela_extra, valor_extra)) + links.insert(0, get_link(tabela_extra, valor_extra, slug)) return sql, links @@ -303,16 +304,15 @@ def get_url(slug): def get_sqls_desexcluir_criar(desexcluir, criar, slug): - sqls_links = [get_sql(*args) + sqls_links = [get_sql(*(args + [slug])) for itens, get_sql in ((desexcluir, get_sql_desexcluir), (criar, get_sql_criar)) for args in itens] if not sqls_links: return '' else: - url_base = get_url(slug) sqls, links = zip(*sqls_links) - links = [url_base + l for ll in links for l in ll] # flatten + links = [l for ll in links for l in ll] # flatten sqls, links = ['\n'.join(sorted(s)) for s in [sqls, links]] return TEMPLATE_RESSUCITADOS.format(links, sqls)