changes
This commit is contained in:
@@ -85,9 +85,9 @@ def create_listing():
|
||||
return render_template('create_listing.html')
|
||||
|
||||
@app.route('/booking/<int:listing_id>', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def booking(listing_id):
|
||||
listing = Listing.query.get_or_404(listing_id)
|
||||
|
||||
booked_dates = Booking.query.filter_by(listing_id=listing_id).all()
|
||||
unavailable_dates = [
|
||||
(booking.check_in.strftime('%Y-%m-%d'), booking.check_out.strftime('%Y-%m-%d'))
|
||||
@@ -95,13 +95,10 @@ def booking(listing_id):
|
||||
]
|
||||
|
||||
if request.method == 'POST':
|
||||
guest_name = request.form['name']
|
||||
email = request.form['email']
|
||||
phone = request.form['phone']
|
||||
check_in = datetime.strptime(request.form['check_in'], '%Y-%m-%d')
|
||||
check_out = datetime.strptime(request.form['check_out'], '%Y-%m-%d')
|
||||
guests = request.form['guests']
|
||||
booking = Booking(guest_name=guest_name, email=email, phone=phone, listing_id=listing_id, check_in=check_in, check_out=check_out, guests=guests)
|
||||
booking = Booking(user_id=current_user.id, listing_id=listing_id, check_in=check_in, check_out=check_out, guests=guests)
|
||||
db.session.add(booking)
|
||||
db.session.commit()
|
||||
return redirect(url_for('home'))
|
||||
|
||||
Reference in New Issue
Block a user