From 0bdd52543e51c9dca6467010cea61d5e7a49b4e3 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Mon, 24 Oct 2016 13:44:06 -0200 Subject: [PATCH] Trata inexist de arq template passado p menus.py --- sapl/base/apps.py | 24 +----------------------- sapl/base/templatetags/menus.py | 9 +++++++-- sapl/crud/base.py | 1 + 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/sapl/base/apps.py b/sapl/base/apps.py index 9c0bf33b0..0ca7a90cd 100644 --- a/sapl/base/apps.py +++ b/sapl/base/apps.py @@ -102,35 +102,13 @@ def create_proxy_permissions( print("Adding permission '%s'" % perm) -def run_sql_organizers( - app_config, verbosity=2, interactive=True, - using=DEFAULT_DB_ALIAS, **kwargs): - """with connection.cursor() as cursor: - for line in lines: - line = line.strip() - if not line or line.startswith('#'): - continue - - try: - cursor.execute(line)""" - - print('aqui run_sql_organizer', app_config) - -""" update protocoloadm_protocolo set autor_id = null; -delete from materia_autoria; -delete from materia_proposicao; - -delete from materia_tipoproposicao; -""" - - class AppConfig(django.apps.AppConfig): name = 'sapl.base' label = 'base' verbose_name = _('Dados Básicos') def ready(self): - pre_migrate.connect(run_sql_organizers, self) + #pre_migrate.connect(run_sql_organizers, self) post_migrate.connect( receiver=create_proxy_permissions, diff --git a/sapl/base/templatetags/menus.py b/sapl/base/templatetags/menus.py index 6e8b4f4a3..a839ed680 100644 --- a/sapl/base/templatetags/menus.py +++ b/sapl/base/templatetags/menus.py @@ -1,10 +1,11 @@ -import yaml from django import template from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +import yaml from sapl.utils import sapl_logger + register = template.Library() @@ -55,14 +56,18 @@ def subnav(context, path=None): if not yaml_path: return - try: """ Por padrão, são carragados dois Loaders, filesystem.Loader - busca em TEMPLATE_DIRS do projeto atual app_directories.Loader - busca em todas apps instaladas A função nativa abaixo busca em todos os Loaders Configurados. """ + try: yaml_template = template.loader.get_template(yaml_path) + except: + return + + try: rendered = yaml_template.render() menu = yaml.load(rendered) resolve_urls_inplace(menu, root_pk, rm, context) diff --git a/sapl/crud/base.py b/sapl/crud/base.py index 127312cd0..81450172d 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -1164,6 +1164,7 @@ class MasterDetailCrud(Crud): return context + @property def cancel_url(self): if self.list_url: return self.list_url