from django import template
import settings
register = template.Library()
class ShowGoogleAnalyticsJS(template.Node):
def render(self, context):
code = getattr(settings, "GOOGLE_ANALYTICS_CODE", False)
if not code:
return ""
if 'user' in context and context['user'] and context['user'].is_staff:
return ""
if settings.DEBUG:
return ""
return """
"""
def googleanalyticsjs(parser, token):
return ShowGoogleAnalyticsJS()
show_common_data = register.tag(googleanalyticsjs)