From ac262169ef707e9f179378e7a66bfc546507acde Mon Sep 17 00:00:00 2001 From: 3err0 Date: Thu, 30 Jan 2025 14:38:53 +0800 Subject: [PATCH] bookings list --- routes.py | 3 ++- templates/dashboard.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/routes.py b/routes.py index c8d2c86..ef4373b 100644 --- a/routes.py +++ b/routes.py @@ -96,7 +96,8 @@ def dashboard(): listings = Listing.query.filter_by(host_id=current_user.id).all() users = User.query.all() documents = {doc.user_id: doc for doc in Document.query.all()} - return render_template('dashboard.html', listings=listings, users=users, documents=documents) + bookings = Booking.query.join(Listing).filter(Listing.host_id == current_user.id).all() + return render_template('dashboard.html', listings=listings, users=users, documents=documents, bookings=bookings) return redirect(url_for('home')) @app.route('/create-listing', methods=['GET', 'POST']) diff --git a/templates/dashboard.html b/templates/dashboard.html index afd7899..8b5d25b 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -34,6 +34,35 @@ +
+

Bookings

+
+ + + + + + + + + + + + + {% for booking in bookings %} + + + + + + + + + {% endfor %} + +
Booked By (User ID)ListingLocationProperty TypeCheck-inCheck-out
{{ booking.user_id }}{{ booking.listing.title if booking.listing else 'Unknown' }}{{ booking.listing.location if booking.listing else 'Unknown' }}{{ booking.listing.property_type if booking.listing else 'Unknown' }}{{ booking.check_in.strftime('%Y-%m-%d') }}{{ booking.check_out.strftime('%Y-%m-%d') }}
+
+

Registered Users