Пример #1
0
def passenger_home(request):
    if not request.mobile and CURRENT_PASSENGER_KEY in request.session:
        del request.session[CURRENT_PASSENGER_KEY]

    hidden_fields = HIDDEN_FIELDS
    form = OrderForm()
    not_a_user, not_a_passenger = NOT_A_USER, NOT_A_PASSENGER
    waze_token = settings.WAZE_API_TOKEN
    telmap_user = settings.TELMAP_API_USER
    telmap_password = settings.TELMAP_API_PASSWORD
    telmap_languages = "he" if str(get_language_from_request(request)) == "he" else "en"
    country_code = settings.DEFAULT_COUNTRY_CODE
    service_cities = ", ".join(set([s.city.name for s in Station.objects.filter(show_on_list=True)]))
    passenger = Passenger.from_request(request)

    if not passenger and request.GET.get("show_login", False):
        show_login = True

    if passenger and passenger.business:
        PENDING = models.PENDING
        ASSIGNED = models.ASSIGNED
        ACCEPTED = models.ACCEPTED
        ORDER_FAILED = models.FAILED  # groups together FAILED, ERROR and TIMED_OUT
        ORDER_MAX_WAIT_TIME = models.ORDER_MAX_WAIT_TIME
        FAILED_MSG = _(order_tracker.STATUS_MESSAGES[models.FAILED])

        show_tracker = True
        channel_key = get_channel_key(Passenger.from_request(request), request.session.session_key)
        init_token = channel.create_channel(channel_key)
        init_tracker_history = [simplejson.dumps(msg) for msg in order_tracker.get_tracker_history(passenger)]

    return custom_render_to_response("passenger_home.html", locals(), context_instance=RequestContext(request))
Пример #2
0
def station_business_page(request, subdomain_name=None):
    if not subdomain_name:
        subdomain_name = get_station_domain(request)
    station = get_object_or_404(models.Station, subdomain_name=subdomain_name)
    passenger = Passenger.from_request(request)

    if not passenger:
        return auth_views.login(request, template_name="business_login.html")
#    only in django 1.3
#        return auth_views.login(request, template_name="business_login.html", extra_context={'station': station})
    elif not passenger.business:
        return HttpResponseForbidden("You are not a business")

    business = passenger.business
    cities = City.objects.filter(country=passenger.country)
    cities = filter(lambda city: is_in_hebrew(city.name), cities)
    cities = sorted(cities, key=lambda city: city.name)

    PENDING = models.PENDING
    ASSIGNED = models.ASSIGNED
    ACCEPTED = models.ACCEPTED
    ORDER_FAILED = models.FAILED # groups together FAILED, ERROR and TIMED_OUT
    ORDER_MAX_WAIT_TIME = models.ORDER_MAX_WAIT_TIME
    FAILED_MSG = _(order_tracker.STATUS_MESSAGES[models.FAILED])

    channel_key = get_channel_key(Passenger.from_request(request), request.session.session_key)
    passenger.cleanup_session_keys()
    passenger.session_keys.append(request.session.session_key)
    passenger.save()

    init_token = channel.create_channel(channel_key)
    init_tracker_history = [simplejson.dumps(msg) for msg in order_tracker.get_tracker_history(passenger)]

    return custom_render_to_response("station_page_business.html", locals(), context_instance=RequestContext(request))
Пример #3
0
def get_tracker_init(request):
    response = ''
    passenger = Passenger.from_request(request)
    if passenger:
        channel_key = get_channel_key(passenger, request.session.session_key)
        token = channel.create_channel(channel_key)
        tracker_history = order_tracker.get_tracker_history(passenger)

        response = {'tracker_history': tracker_history, 'token': token}

    return JSONResponse(response)
Пример #4
0
def get_tracker_init(request):
    response = ""
    passenger = Passenger.from_request(request)
    if passenger:
        channel_key = get_channel_key(passenger, request.session.session_key)
        token = channel.create_channel(channel_key)
        tracker_history = order_tracker.get_tracker_history(passenger)

        response = {"tracker_history": tracker_history, "token": token}

    return JSONResponse(response)
Пример #5
0
def passenger_home(request):
    if not request.mobile and CURRENT_PASSENGER_KEY in request.session:
        del request.session[CURRENT_PASSENGER_KEY]

    hidden_fields = HIDDEN_FIELDS
    form = OrderForm()
    not_a_user, not_a_passenger = NOT_A_USER, NOT_A_PASSENGER
    waze_token = settings.WAZE_API_TOKEN
    telmap_user = settings.TELMAP_API_USER
    telmap_password = settings.TELMAP_API_PASSWORD
    telmap_languages = 'he' if str(
        get_language_from_request(request)) == 'he' else 'en'
    country_code = settings.DEFAULT_COUNTRY_CODE
    service_cities = ", ".join(
        set([s.city.name for s in Station.objects.filter(show_on_list=True)]))
    passenger = Passenger.from_request(request)

    if not passenger and request.GET.get("show_login", False):
        show_login = True

    if passenger and passenger.business:
        PENDING = models.PENDING
        ASSIGNED = models.ASSIGNED
        ACCEPTED = models.ACCEPTED
        ORDER_FAILED = models.FAILED  # groups together FAILED, ERROR and TIMED_OUT
        ORDER_MAX_WAIT_TIME = models.ORDER_MAX_WAIT_TIME
        FAILED_MSG = _(order_tracker.STATUS_MESSAGES[models.FAILED])

        show_tracker = True
        channel_key = get_channel_key(Passenger.from_request(request),
                                      request.session.session_key)
        init_token = channel.create_channel(channel_key)
        init_tracker_history = [
            simplejson.dumps(msg)
            for msg in order_tracker.get_tracker_history(passenger)
        ]

    return custom_render_to_response("passenger_home.html",
                                     locals(),
                                     context_instance=RequestContext(request))