Ejemplo n.º 1
0
def remove_pax_from_booking(booking_id, service_no):
  b = db.Key.from_path('Booking', booking_id)
  p = db.Key.from_path('Passenger', service_no)
  psb = PassengerSectorBooking.all(keys_only=True)
  psb.filter('booking = ', b)
  psb.filter('passenger = ', p)
  _use(p)
  _use(b)
  db.delete(psb)
Ejemplo n.º 2
0
def get_bookings_by_passenger_sn(service_no, course=None, active_only=False):
  p = db.Key.from_path('Passenger', service_no)
  q = PassengerSectorBooking.all()
  q.filter('passenger = ', p)

  res = {}
  for psb in q:
    res[psb.booking.key().id()] = psb.booking.to_dict()

  return res.values()
Ejemplo n.º 3
0
def add_passenger_to_sector(sector_id, service_no, last_name=None, init=None, fare=None):
  s = Sector.get_by_id(sector_id)
  p = Passenger.get_by_key_name(service_no)

  if not p and last_name and init:
    p = Passenger(service_no=service_no, key_name=service_no, last_name=last_name, init=init)
    p.put()

  if p and s:
    psb = PassengerSectorBooking(passenger=p, sector=s, booking=s.booking, fare_type=fare, key_name=str(p.key())+str(s.key()))
    psb.put()

    _use(s.booking.key())
    _use(p.key())

    res = p.to_dict()
    res['fare'] = fare
    return res

  return None
Ejemplo n.º 4
0
def get_passenger_by_booking_id(booking_id):
  b = db.Key.from_path('Booking', booking_id)
  q = PassengerSectorBooking.all()
  q.filter('booking = ', b)

  res = {}
  for psb in q:
    p = psb.passenger.to_dict()
    res[p['service_no']] = p

  return res.values()
Ejemplo n.º 5
0
def get_passenger_fares_by_sector_id(sector_id):
  s = db.Key.from_path('Sector', sector_id)
  q = PassengerSectorBooking.all()
  q.filter('sector = ', s)
  
  res = []
  for psb in q:
    p = psb.passenger.to_dict()
    p['fare'] = psb.fare_type
    res.append(p)

  return res
Ejemplo n.º 6
0
def update_passenger_fare(service_no, sector_id, fare_type):
  s = db.Key.from_path('Sector', sector_id)
  p = db.Key.from_path('Passenger', service_no)
  psb = PassengerSectorBooking.get_by_key_name(str(p)+str(s))

  res = None

  if psb:
    psb.fare_type = fare_type
    psb.put()
    _use(psb.booking.key())
    _use(psb.passenger.key())

  res = psb.passenger.to_dict()
  res['fare'] = fare_type

  return res
Ejemplo n.º 7
0
def get_sectors_by_passenger_sn(service_no):
  p = db.Key.from_path('Passenger', service_no)
  psb = PassengerSectorBooking.all()
  psb.filter('passenger = ', p)

  return [r.sector.to_dict() for r in psb]