Create IS_TENANT_SITE context variable
This commit is contained in:
parent
028a27c538
commit
33cf6cdd2b
2 changed files with 14 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
{% if request.COOKIES.gdpr_accepted %}
|
{% if request.COOKIES.gdpr_accepted or IS_TENANT_SITE %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<style>
|
<style>
|
||||||
div#gdprBanner {
|
div#gdprBanner {
|
||||||
|
|
|
@ -5,18 +5,27 @@ def google_analytics(request):
|
||||||
"""
|
"""
|
||||||
Use the variables returned in this function to
|
Use the variables returned in this function to
|
||||||
render your Google Analytics tracking code template.
|
render your Google Analytics tracking code template.
|
||||||
|
|
||||||
|
Also check whether the site is a tenant site and create a corresponding
|
||||||
|
variable to indicate this
|
||||||
"""
|
"""
|
||||||
host = request.get_host()
|
host = request.get_host()
|
||||||
ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(
|
ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS', False).get(
|
||||||
host)
|
host)
|
||||||
|
which_urlspy = settings.MULTISITE_CMS_URLS.get(host)
|
||||||
if ga_prop_id is None:
|
if ga_prop_id is None:
|
||||||
# Try checking if we have a www in host, if yes we remove
|
# Try checking if we have a www in host, if yes we remove
|
||||||
# that and check in the dict again
|
# that and check in the dict again
|
||||||
if host.startswith('www.'):
|
if host.startswith('www.'):
|
||||||
ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS',
|
ga_prop_id = getattr(settings, 'GOOGLE_ANALYTICS_PROPERTY_IDS',
|
||||||
False).get(host[4:])
|
False).get(host[4:])
|
||||||
|
which_urlspy = settings.MULTISITE_CMS_URLS.get(host[4:])
|
||||||
|
return_dict = {}
|
||||||
if not settings.DEBUG and ga_prop_id:
|
if not settings.DEBUG and ga_prop_id:
|
||||||
return {
|
return_dict['GOOGLE_ANALYTICS_PROPERTY_ID'] = ga_prop_id
|
||||||
'GOOGLE_ANALYTICS_PROPERTY_ID': ga_prop_id
|
|
||||||
}
|
if which_urlspy:
|
||||||
return {}
|
if which_urlspy.endswith("multi"):
|
||||||
|
return_dict['IS_TENANT_SITE'] = True
|
||||||
|
|
||||||
|
return return_dict
|
||||||
|
|
Loading…
Reference in a new issue