def get_passengers_by_name(last_name, init=None): q = Passenger.all() q.filter('last_name >= ', last_name) q.filter('last_name < ', last_name + u'\ufffd') if init: q.filter('init = ', init) q.order('last_name') q.order('init') return [p.to_dict() for p in q]
def update_passenger(service_no, **kwds): p = Passenger.get_by_key_name(service_no) if p and len(kwds) > 0: if 'last_name' in kwds: p.last_name = kwds['last_name'] if 'init' in kwds: p.init = kwds['init'] p.put() _use(p.key()) return p.to_dict()
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
def get_passenger_by_sn(service_no): p = Passenger.get_by_key_name(service_no) if p: return p.to_dict() return None