Exemplo n.º 1
0
def kbsite(request):
    kbsite = getattr(request, 'kbsite', None)

    ret = {
        'DEBUG': settings.DEBUG,
        'EMBEDDED': getattr(settings, 'EMBEDDED', False),
        'EPOCH': pykeg.EPOCH,
        'VERSION': pykeg.__version__,
        'HAVE_SESSIONS': False,
        'HAVE_ADMIN': settings.KEGBOT_ENABLE_ADMIN,
        'GOOGLE_ANALYTICS_ID': None,
        'kbsite': kbsite,
        'request_path': request.path,
        'login_form': LoginForm(initial={'next_page': request.path}),
        'guest_info': {
            'name': 'guest',
            'image': None,
        },
        'PLUGINS': getattr(request, 'plugins', {}),
    }

    if kbsite:
        ret['guest_info']['name'] = kbsite.settings.guest_name
        ret['guest_info']['image'] = kbsite.settings.guest_image
        ret['SERIAL_NUMBER'] = kbsite.serial_number
        ret['HAVE_SESSIONS'] = models.DrinkingSession.objects.all().count() > 0
        ret['GOOGLE_ANALYTICS_ID'] = kbsite.settings.google_analytics_id

    return ret
def kbsite(request):
    ret = {
        'kbsite': getattr(request, 'kbsite', None),
        'request_path': request.path,
        'login_form': LoginForm(initial={'next_page': request.path}),
    }
    return ret
Exemplo n.º 3
0
def kbsite(request):
    kbsite = getattr(request, 'kbsite', None)

    redir = urllib.urlencode(
        {'redir': request.build_absolute_uri(request.path)})

    sso_login_url = getattr(settings, 'SSO_LOGIN_URL', '')
    if sso_login_url:
        sso_login_url = '{}?{}'.format(sso_login_url, redir)

    sso_logout_url = getattr(settings, 'SSO_LOGOUT_URL', '')
    if sso_logout_url:
        sso_logout_url = '{}?{}'.format(sso_logout_url, redir)

    ret = {
        'DEBUG': settings.DEBUG,
        'DEMO_MODE': settings.DEMO_MODE,
        'EMBEDDED': settings.EMBEDDED,
        'EPOCH': pykeg.EPOCH,
        'VERSION': util.get_version(),
        'HAVE_SESSIONS': False,
        'HAVE_ADMIN': settings.KEGBOT_ENABLE_ADMIN,
        'GOOGLE_ANALYTICS_ID': None,
        'SSO_LOGIN_URL': sso_login_url,
        'SSO_LOGOUT_URL': sso_logout_url,
        'CAN_INVITE': kbsite.can_invite(request.user) if kbsite else False,
        'kbsite': kbsite,
        'request_path': request.path,
        'login_form': LoginForm(initial={'next_page': request.path}),
        'guest_info': {
            'name': 'guest',
            'image': None,
        },
        'PLUGINS': getattr(request, 'plugins', {}),
    }

    if kbsite:
        ret['guest_info']['name'] = kbsite.guest_name
        ret['guest_info']['image'] = kbsite.guest_image
        ret['HAVE_SESSIONS'] = models.DrinkingSession.objects.all().count() > 0
        ret['GOOGLE_ANALYTICS_ID'] = kbsite.google_analytics_id
        ret['metric_volumes'] = (kbsite.volume_display_units == 'metric')
        ret['temperature_display_units'] = kbsite.temperature_display_units

    return ret
Exemplo n.º 4
0
def kbsite(request):
    kbsite = getattr(request, 'kbsite', None)
    analytics_id = None
    if kbsite:
        analytics_id = kbsite.settings.google_analytics_id

    guest_info = {
        'name': 'guest',
        'image': None,
    }
    if kbsite:
        guest_info['name'] = kbsite.settings.guest_name
        guest_info['image'] = kbsite.settings.guest_image

    ret = {
        'kbsite': getattr(request, 'kbsite', None),
        'request_path': request.path,
        'login_form': LoginForm(initial={'next_page': request.path}),
        'GOOGLE_ANALYTICS_ID': analytics_id,
        'guest_info': guest_info,
    }
    return ret
Exemplo n.º 5
0
def kbsite(request):
    kbsite = getattr(request, "kbsite", None)

    redir = urllib.parse.urlencode({"redir": request.build_absolute_uri(request.path)})

    sso_login_url = getattr(settings, "SSO_LOGIN_URL", "")
    if sso_login_url:
        sso_login_url = "{}?{}".format(sso_login_url, redir)

    sso_logout_url = getattr(settings, "SSO_LOGOUT_URL", "")
    if sso_logout_url:
        sso_logout_url = "{}?{}".format(sso_logout_url, redir)

    ret = {
        "DEBUG": settings.DEBUG,
        "VERSION": util.get_version(),
        "HAVE_SESSIONS": False,
        "KEGBOT_ENABLE_ADMIN": settings.KEGBOT_ENABLE_ADMIN,
        "ENABLE_SENSING": kbsite.enable_sensing if kbsite else True,
        "ENABLE_USERS": kbsite.enable_users if kbsite else True,
        "GOOGLE_ANALYTICS_ID": None,
        "SSO_LOGIN_URL": sso_login_url,
        "SSO_LOGOUT_URL": sso_logout_url,
        "CAN_INVITE": kbsite.can_invite(request.user) if kbsite else False,
        "kbsite": kbsite,
        "request_path": request.path,
        "login_form": LoginForm(initial={"next_page": request.path}),
        "guest_info": {"name": "guest", "image": None,},
        "PLUGINS": getattr(request, "plugins", {}),
    }

    if kbsite:
        ret["HAVE_SESSIONS"] = models.DrinkingSession.objects.all().count() > 0
        ret["GOOGLE_ANALYTICS_ID"] = kbsite.google_analytics_id
        ret["metric_volumes"] = kbsite.volume_display_units == "metric"
        ret["temperature_display_units"] = kbsite.temperature_display_units

    return ret