From b0db7aa666eb57a397fac2bf43c6c28f4800fd60 Mon Sep 17 00:00:00 2001 From: Emmanuel Cohen Date: Tue, 28 Apr 2015 14:50:49 +0200 Subject: [PATCH] Fix exeception for templetags (works on django 1.7/py3.4 & django 1.6/py2.7) --- helpdesk/templatetags/load_helpdesk_settings.py | 12 ++++++------ helpdesk/templatetags/saved_queries.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/helpdesk/templatetags/load_helpdesk_settings.py b/helpdesk/templatetags/load_helpdesk_settings.py index c00579e0..f14e4b30 100644 --- a/helpdesk/templatetags/load_helpdesk_settings.py +++ b/helpdesk/templatetags/load_helpdesk_settings.py @@ -9,13 +9,13 @@ from django.template import Library from helpdesk import settings as helpdesk_settings_config def load_helpdesk_settings(request): -# try: + try: return helpdesk_settings_config -# except Exception, e: -# import sys -# print >> sys.stderr, "'load_helpdesk_settings' template tag (django-helpdesk) crashed with following error:" -# print >> sys.stderr, e -# return '' + except Exception as e: + import sys + print >> sys.stderr, "'load_helpdesk_settings' template tag (django-helpdesk) crashed with following error:" + print >> sys.stderr, e + return '' register = Library() register.filter('load_helpdesk_settings', load_helpdesk_settings) diff --git a/helpdesk/templatetags/saved_queries.py b/helpdesk/templatetags/saved_queries.py index 5c8d3a34..ebedf9bb 100644 --- a/helpdesk/templatetags/saved_queries.py +++ b/helpdesk/templatetags/saved_queries.py @@ -12,14 +12,14 @@ from helpdesk.models import SavedSearch def saved_queries(user): -# try: + try: user_saved_queries = SavedSearch.objects.filter(Q(user=user) | Q(shared__exact=True)) return user_saved_queries -# except Exception, e: -# import sys -# print >> sys.stderr, "'saved_queries' template tag (django-helpdesk) crashed with following error:" -# print >> sys.stderr, e -# return '' + except Exception as e: + import sys + print >> sys.stderr, "'saved_queries' template tag (django-helpdesk) crashed with following error:" + print >> sys.stderr, e + return '' register = Library() register.filter('saved_queries', saved_queries)