예제 #1
0
def transform(bkng):
    to_date = lambda sstr: date_helper.to_date(sstr)
    bkng['quantity'] = int(bkng['quantity'])
    bkng['guests'] = int(bkng['guests'])
    bkng['start'] = to_date(bkng['start'])
    bkng['end'] = to_date(bkng['end'])
    bkng['bookable'] = BookableModel.get_by_id(long(bkng['bookable']))
    return bkng
    pass
예제 #2
0
def get_bookings_for_bookable(entity_id):
    bookable = BookableModel.get_by_id(entity_id)
    bookings = bookable.get_bookings_that_end_after(datetime.today())
    bookings = [{
        'start': date.to_str(e.start),
        'end': date.to_str(e.end),
        'quantity': e.quantity
    } for e in bookings]

    return json.dumps(bookings)
예제 #3
0
def admin_move_bookable(entityId):
    bookable = BookableModel.get_by_id(entityId)
    jsd = request_helper.get_json_data()
    bookable.category = CategoryModel.get_by_id(long(jsd['category_id']))
    bookable.put()
    return json.dumps(bookable.to_dict())
예제 #4
0
def admin_delete_bookable(entity_id):
    if request.method == 'DELETE' or request.values['_method'] == 'DELETE':
        BookableModel.get_by_id(entity_id).delete()
        return "{ 'value' : 'OK' }"
    pass