예제 #1
0
파일: views.py 프로젝트: ralka/onefinestay
def airport_info(request):
    today = datetime.today()
    bookings = request.user.booking_set.filter(date_from__startswith=today.date())
    cities = bookings.values('city').distinct()
    codes = Airport.objects.filter(city__in = cities).values('code')
    codes = [(a["code"]) for a in codes]
    service = AirInfo.factory('fltstats')
    aptsDelay = service.getDelayAptIndex(codes)
    
    return render_to_response('arriveontime/airport_info.html',
                          {'aptsDelay':aptsDelay},
                          context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: ralka/onefinestay
def check_flight(request,bookingId,user_flight_number=False):
    booking = get_object_or_404(Booking,pk=bookingId)
    date_from = booking.date_from
    if user_flight_number:
        flight_number = user_flight_number
    else:
        flight_number = booking.flight_number
        
    
    service = AirInfo.factory('fltstats')

    flightInfo = service.getFlightArrival(flight_number[0:2],flight_number[2:],date_from.year,date_from.month,date_from.day)

    if len(flightInfo) == 0:
        flightInfo = dict()
        flightInfo["number"] = flight_number
        flightInfo["bookingId"] = bookingId
        return render_to_response('arriveontime/no_flight_info.html',
                          {'flightInfo':flightInfo},
                          context_instance=RequestContext(request))
    else:    
        return render_to_response('arriveontime/check_flight.html',
                          {'flightInfo':flightInfo,'user_flight_number':user_flight_number,"bookingId":bookingId},
                          context_instance=RequestContext(request))