2015-04-09 06:13:05 -06:00
|
|
|
from django.conf import settings
|
|
|
|
from django.template.loader import render_to_string
|
2017-12-16 17:50:44 -07:00
|
|
|
from django.utils.timezone import now
|
2015-04-09 06:13:05 -06:00
|
|
|
|
2017-12-16 17:50:44 -07:00
|
|
|
from network.base.models import Observation
|
2017-12-14 12:28:15 -07:00
|
|
|
|
2015-04-09 06:13:05 -06:00
|
|
|
|
|
|
|
def analytics(request):
|
|
|
|
"""Returns analytics code."""
|
|
|
|
if settings.ENVIRONMENT == 'production':
|
2017-02-21 14:52:39 -07:00
|
|
|
return {'analytics_code': render_to_string('includes/analytics.html')}
|
2015-04-09 06:13:05 -06:00
|
|
|
else:
|
|
|
|
return {'analytics_code': ''}
|
2015-05-10 04:31:10 -06:00
|
|
|
|
|
|
|
|
|
|
|
def stage_notice(request):
|
|
|
|
"""Displays stage notice."""
|
|
|
|
if settings.ENVIRONMENT == 'stage':
|
|
|
|
return {'stage_notice': render_to_string('includes/stage_notice.html')}
|
|
|
|
else:
|
|
|
|
return {'stage_notice': ''}
|
2017-12-14 12:28:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
def user_processor(request):
|
|
|
|
if request.user.is_authenticated():
|
|
|
|
owner_vetting_count = Observation.objects.filter(author=request.user,
|
2017-12-16 17:50:44 -07:00
|
|
|
vetted_status='unknown',
|
|
|
|
end__lt=now()).count()
|
|
|
|
return {'owner_vetting_count': owner_vetting_count}
|
2017-12-14 12:28:15 -07:00
|
|
|
else:
|
2017-12-16 17:50:44 -07:00
|
|
|
return {'owner_vetting_count': ''}
|
2018-12-14 07:57:05 -07:00
|
|
|
|
|
|
|
|
|
|
|
def auth_block(request):
|
|
|
|
"""Displays auth links local vs auth0."""
|
|
|
|
if settings.AUTH0:
|
|
|
|
return {'auth_block': render_to_string('includes/auth_auth0.html')}
|
|
|
|
else:
|
|
|
|
return {'auth_block': render_to_string('includes/auth_local.html')}
|