mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Use different mixpanel tokens while deployed vs in development
(imported from commit 4fac466a822d49cb0e1a7592dbd77d8ee019803e)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user