def send_heartbeat(request):
    current_version = get_current_version()
    for ws in WorkStation.objects.filter(is_online=True):
        logging.info("sending heartbeat to: %s" % ws)
        _do_push(ws, {"heartbeat": current_version})

    return HttpResponse("OK")
def send_heartbeat(request):
    current_version = get_current_version()
    for ws in WorkStation.objects.filter(is_online=True):
        logging.info("sending heartbeat to: %s" % ws)
        _do_push(ws, {"heartbeat": current_version})

    return HttpResponse("OK")
def _send_order_with_version(orders):
    """
    Add version information and send orders to client

    @param orders: a list of order objects to send
    @return: a JSONResponse
    """
    return JSONResponse({"orders": orders,
                         "version": get_current_version()
    })
def sharing_workstation_home(request, work_station, workstation_id):
    from sharing.sharing_dispatcher import WS_SHOULD_HANDLE_TIME
    if work_station.id != int(workstation_id):
        logout(request)
        return HttpResponseRedirect(request.path)

    handle_time = WS_SHOULD_HANDLE_TIME

    channel_token = channel.create_channel(work_station.generate_new_channel_id())
    current_version = get_current_version()
    station_name = work_station.station.name

    return render_to_response('ws_home.html', locals(), context_instance=RequestContext(request))
def sharing_workstation_home(request, work_station, workstation_id):
    from sharing.sharing_dispatcher import WS_SHOULD_HANDLE_TIME
    if work_station.id != int(workstation_id):
        logout(request)
        return HttpResponseRedirect(request.path)

    handle_time = WS_SHOULD_HANDLE_TIME

    channel_token = channel.create_channel(
        work_station.generate_new_channel_id())
    current_version = get_current_version()
    station_name = work_station.station.name

    return render_to_response('ws_home.html',
                              locals(),
                              context_instance=RequestContext(request))
def workstation_home(request, work_station, workstation_id):
#    if not random.randint(0, 1):
#        return HttpResponseBadRequest("Just a test")

    if work_station.station.subdomain_name not in ["ny", "media"]:
        shutdown = True

    request.session["django_language"] = "he" # hardcode hebrew for stations
    show_version_error = True and not settings.LOCAL

    air_version = re.search("AdobeAIR/([\d.]+)", request.META.get("HTTP_USER_AGENT", ""))
    if air_version:
        if air_version.groups()[0] >= "3.0.0":
            show_version_error = False

    if work_station.id != int(workstation_id):
        logout(request)
        return HttpResponseRedirect(request.path)
    station_name = work_station.station.name
    station_rating = work_station.station.average_rating
    polling_interval = settings.POLLING_INTERVAL
    pending = PENDING
    assigned = ASSIGNED
    accept = ACCEPT
    reject = REJECT
    online = ONLINE
    offline = OFFLINE
    pickup_times = [1, 3, 5, 7, 10, 15, 20]
    timeout_interval = ORDER_ASSIGNMENT_TIMEOUT - 1
    teaser_interval = ORDER_TEASER_TIMEOUT - 1
    heartbeat_timeout_interval = 1000 * models.WORKSTATION_HEARTBEAT_TIMEOUT_INTERVAL
    is_popup = True
    station_rating = work_station.station.average_rating
    connection_check_key = station_connection_manager.CONNECTION_CHECK_KEY
    connection_check_interval = station_connection_manager.CONNECTION_CHECK_INTERVAL
    token = channel.create_channel(work_station.generate_new_channel_id())
    current_version = get_current_version()
    return render_to_response("workstation_home.html", locals())
def current_version(request, work_station):
    if work_station.is_online:
        return JSONResponse(get_current_version())
    else:
        return JSONResponse(0) # cause a refresh of the module