예제 #1
0
def moreInfo(hotel_id):
    logger.info("Got a more info page request: %s" % request)
    db = AndrewDB()
    form = ReserveRoomForm()
    form.csrf_enabled = False
    search = session['search']
    search['hotel_id'] = hotel_id
    if request.method == 'POST':
        info = form.data
        info['customer_id'] = current_user.user_id
        checkin = datetime.datetime.strptime(search['checkin'],
                                             '%Y-%m-%d').date()
        checkout = datetime.datetime.strptime(search['checkout'],
                                              '%Y-%m-%d').date()
        nights = (checkout - checkin).days
        cost = db.get_cost_by_id(form.room_id.data)
        info['amount'] = int(form.quantity.data) * nights * int(cost)
        info['transaction_id'] = db.create_transaction_get_id(info)
        db.add_booking(info)
        flash('Room was reserved')
        logger.info("Room with ID=%s was reserved" % form.room_id.data)
    hotel = db.get_vw_hotel_by_id(hotel_id)
    rooms = db.search_get_rooms(search)
    cust_info = db.get_vw_customer_by_id(current_user.user_id)
    logger.info("Rendering the More info page")
    return render_template('booking.html',
                           form=form,
                           search=search,
                           hotel=hotel,
                           rooms=rooms,
                           cust_info=cust_info)
예제 #2
0
def test_add_booking(mock_connect):
    with allure.step('Add booking'):
        with app.app_context():
            db = AndrewDB()
            db.add_booking({})