Exemplo n.º 1
0
def delete_booking_by_id(booking_id):
  b = Booking.get_by_id(booking_id)

  if b:
    db.delete(b.documents)
    db.delete(b.sectors)
    db.delete(b.passengers_rel)

  db.delete_async(db.Key.from_path('LastUse', str(b.key())))
  b.delete()
Exemplo n.º 2
0
def add_sector(booking_id, date, from_loc, to_loc, service):
  res = None
  b = Booking.get_by_id(booking_id)

  if b:
    res = Sector(date=date, from_loc=from_loc, to_loc=to_loc, service=service, booking=b)
    res.put()
    
    if date > b.last_date:
      b.last_date = date
      b.put()

    _use(b.key())

  return res.to_dict()
Exemplo n.º 3
0
def update_booking(booking_id, **kwds):
  b = Booking.get_by_id(booking_id)

  if b and len(kwds) > 0:
    if 'booking_ref' in kwds:
      b.booking_ref = kwds['booking_ref']

    if 'company' in kwds:
      b.company = kwds['company']

    if 'course' in kwds:
      b.course = kwds['course']

    if 'fare' in kwds:
      b.fare = kwds['fare']

    if 'paid_by' in kwds:
      b.paid_by = kwds['paid_by']
      if b.paid_by > b.last_date:
        b.last_date = b.paid_by

    if 'state' in kwds:
      b.state = kwds['state']

    if 'amound_in_credit' in kwds:
      b.amount_in_credit = kwds['amount_in_credit']

    if 'credit_expiry' in kwds:
      b.credit_expiry = kwds['credit_expiry']
      if b.credit_expiry > b.last_date:
        b.last_date = b.credit_expiry

    b.put()
    _use(b.key())

  return b.to_dict()
Exemplo n.º 4
0
def get_booking_by_id(booking_id):
  b = Booking.get_by_id(booking_id)
  if b:
    _use(b.key())
    return b.to_dict()
  return None