From f72ba9e69f456d3e63b8cc7d937a462d7a83a5b8 Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Wed, 15 Oct 2014 19:03:58 -0400 Subject: [PATCH] Overwrite web error message to hide traceback from user Inject sentry_activated into web session Overwrite CrashManager.error QWeb template Provide translations Signed-off-by: Sandy Carter --- sentry_logger/__init__.py | 13 +++++++++++ sentry_logger/__openerp__.py | 8 +++++-- sentry_logger/i18n/fr.po | 32 +++++++++++++++++++++++++++ sentry_logger/i18n/sentry_logger.pot | 30 +++++++++++++++++++++++++ sentry_logger/static/src/xml/base.xml | 25 +++++++++++++++++++++ 5 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 sentry_logger/i18n/fr.po create mode 100644 sentry_logger/i18n/sentry_logger.pot create mode 100644 sentry_logger/static/src/xml/base.xml diff --git a/sentry_logger/__init__.py b/sentry_logger/__init__.py index 888be4dc3..d0b714b9e 100644 --- a/sentry_logger/__init__.py +++ b/sentry_logger/__init__.py @@ -24,6 +24,7 @@ import logging import cgitb from openerp.tools import config +from openerp.addons.web.controllers.main import Session from .odoo_sentry_client import OdooClient from .odoo_sentry_handler import OdooSentryHandler @@ -49,3 +50,15 @@ if config.get(u'sentry_dsn'): else: root_logger.warn(u"Sentry DSN not defined in config file") client = None + + +# Inject sentry_activated to session to display error message or not +old_session_info = Session.session_info + + +def session_info(self, req): + res = old_session_info(self, req) + res['sentry_activated'] = bool(client) + return res + +Session.session_info = session_info diff --git a/sentry_logger/__openerp__.py b/sentry_logger/__openerp__.py index 22708001a..12b48403d 100644 --- a/sentry_logger/__openerp__.py +++ b/sentry_logger/__openerp__.py @@ -21,7 +21,7 @@ ############################################################################## { - 'name': "sentry", + 'name': "Sentry Logger", 'summary': "Sentry integration", 'description': """ @@ -47,7 +47,7 @@ Contributors 'version': '1.0', # any module necessary for this one to work correctly - 'depends': ['base'], + 'depends': ['web'], 'external_dependencies': { 'python': ['raven', 'raven_sanitize_openerp', 'bzrlib', 'git'], }, @@ -57,6 +57,10 @@ Contributors 'demo': [ ], + 'qweb': [ + 'static/src/xml/base.xml', + ], + 'tests': [ ], } diff --git a/sentry_logger/i18n/fr.po b/sentry_logger/i18n/fr.po new file mode 100644 index 000000000..60f983804 --- /dev/null +++ b/sentry_logger/i18n/fr.po @@ -0,0 +1,32 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sentry_logger +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-10-15 22:09+0000\n" +"PO-Revision-Date: 2014-10-15 18:11-0500\n" +"Last-Translator: Sandy Carter \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" +"Language: fr\n" +"X-Generator: Poedit 1.6.9\n" + +#. module: sentry_logger +#. openerp-web +#: code:addons/sentry_logger/static/src/xml/base.xml:8 +#, python-format +msgid "A detailed report has been sent to the technical support team." +msgstr "Un rapport a été envoyé à l'équipe technique." + +#. module: sentry_logger +#. openerp-web +#: code:addons/sentry_logger/static/src/xml/base.xml:7 +#, python-format +msgid "An internal OpenERP error has occurred." +msgstr "Une erreur interne à OpenERP est survenue." diff --git a/sentry_logger/i18n/sentry_logger.pot b/sentry_logger/i18n/sentry_logger.pot new file mode 100644 index 000000000..dd2226936 --- /dev/null +++ b/sentry_logger/i18n/sentry_logger.pot @@ -0,0 +1,30 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sentry_logger +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-10-15 22:09+0000\n" +"PO-Revision-Date: 2014-10-15 22:09+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: sentry_logger +#. openerp-web +#: code:addons/sentry_logger/static/src/xml/base.xml:8 +#, python-format +msgid "A detailed report has been sent to the technical support team." +msgstr "" + +#. module: sentry_logger +#. openerp-web +#: code:addons/sentry_logger/static/src/xml/base.xml:7 +#, python-format +msgid "An internal OpenERP error has occurred." +msgstr "" diff --git a/sentry_logger/static/src/xml/base.xml b/sentry_logger/static/src/xml/base.xml new file mode 100644 index 000000000..ac7ec8cd8 --- /dev/null +++ b/sentry_logger/static/src/xml/base.xml @@ -0,0 +1,25 @@ + + + + + + + +
+

An internal OpenERP error has occurred.

+
+A detailed report has been sent to the technical support team. +
+
+ + +
+
+
+
+
+ +
+
+ +