From c387fccefa98b8658b28ad9b2a8e56617af8d869 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 30 Mar 2017 20:22:08 +0300 Subject: [PATCH] license: report errors raised in context_prossors --- project/customer/context_processors.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/project/customer/context_processors.py b/project/customer/context_processors.py index c65681f..9232668 100644 --- a/project/customer/context_processors.py +++ b/project/customer/context_processors.py @@ -1,9 +1,16 @@ # -*- coding: utf-8 -*- +import traceback from datetime import datetime, timedelta from django.core.cache import cache +from django.core.mail import mail_admins +from django.conf import settings from .models import License +from . import consts + + +DEBUG = getattr(settings, 'DEBUG', False) cache_duration = 3600 @@ -58,5 +65,11 @@ def license_check_soon_ends(request): 'cur_license': cur_license, } except Exception as e: - # print e + if DEBUG: + raise e + else: + mail_admins(subject=u'customer: license_check_soon_ends error', + message=u'Profile id=%s.\n\n%s' % (request.user.profile.pk, traceback.format_exc(e)) + ) + # return { }