Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
is_staff = False
is_superuser = False
if is_user_authenticated(request.user):
is_authenticated = True
if request.user.is_staff:
is_staff = True
if request.user.is_superuser:
is_superuser = True
referer = request.META.get('HTTP_REFERER')
referer_tld = None
referer_tld_string = ''
if referer:
try:
referer_tld = get_tld(referer, as_object=True)
except (TldBadUrl, TldDomainNotFound, TldIOError):
pass
if referer_tld:
referer_tld_string = referer_tld.tld
url = request.get_full_path()
url_query = parse.parse_qs(parse.urlparse(url).query)
# This allows you to measure click rates for ad-campaigns, just
# make sure that your ads have `?campaign=something` in the URL
campaign_keyword = getattr(
settings, 'INFLUXDB_METRICS_CAMPAIGN_KEYWORD', 'campaign')
campaign = ''
if campaign_keyword in url_query:
campaign = url_query[campaign_keyword][0]
data = [{
is_staff = False
is_superuser = False
if request.user.is_authenticated():
is_authenticated = True
if request.user.is_staff:
is_staff = True
if request.user.is_superuser:
is_superuser = True
referer = request.META.get('HTTP_REFERER')
referer_tld = None
referer_tld_string = ''
if referer:
try:
referer_tld = get_tld(referer, as_object=True)
except (TldBadUrl, TldDomainNotFound, TldIOError): # pragma: no cover
pass
if referer_tld:
referer_tld_string = referer_tld.tld
# data
values = {
'ms': ms,
'is_ajax': is_ajax,
'is_authenticated': is_authenticated,
'is_staff': is_staff,
'is_superuser': is_superuser,
'referer': str(referer),
'referer_tld': referer_tld_string,
'full_path': request.get_full_path(),
'method': request.method,
'module': request._view_module,
'view': request._view_name,