Use different mixpanel tokens while deployed vs in development

(imported from commit 4fac466a822d49cb0e1a7592dbd77d8ee019803e)
This commit is contained in:
Zev Benjamin
2013-05-21 12:15:48 -04:00
parent ae9be7298d
commit 22e2eb3305
3 changed files with 20 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import absolute_import
from django.http import HttpResponse, HttpResponseNotAllowed
from django.conf import settings
import django.shortcuts
import simplejson
@@ -30,5 +31,19 @@ def json_success(data={}):
def json_error(msg, data={}, status=400):
return json_response(res_type="error", msg=msg, data=data, status=status)
# We wrap render_to_response so that we can always add some data to
# the template context dictionary. In particular, we add the
# mixpanel token (which varies based on whether we're deployed or
# not) because the mixpanel code is included in base.html.
def render_to_response(template, *args, **kwargs):
if args:
dictionary = args[0]
else:
try:
dictionary = kwargs['dictionary']
except KeyError:
dictionary = {}
kwargs['dictionary'] = dictionary
dictionary['mixpanel_token'] = settings.MIXPANEL_TOKEN
return django.shortcuts.render_to_response(template, *args, **kwargs)