bookings list

This commit is contained in:
2025-01-30 14:38:53 +08:00
parent 4f3ad4d912
commit ac262169ef
2 changed files with 31 additions and 1 deletions
+2 -1
View File
@@ -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'])
+29
View File
@@ -34,6 +34,35 @@
</table>
</div>
</div>
<div class="mt-5">
<h2>Bookings</h2>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Booked By (User ID)</th>
<th>Listing</th>
<th>Location</th>
<th>Property Type</th>
<th>Check-in</th>
<th>Check-out</th>
</tr>
</thead>
<tbody>
{% for booking in bookings %}
<tr>
<td>{{ booking.user_id }}</td>
<td>{{ booking.listing.title if booking.listing else 'Unknown' }}</td>
<td>{{ booking.listing.location if booking.listing else 'Unknown' }}</td>
<td>{{ booking.listing.property_type if booking.listing else 'Unknown' }}</td>
<td>{{ booking.check_in.strftime('%Y-%m-%d') }}</td>
<td>{{ booking.check_out.strftime('%Y-%m-%d') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="mt-5">
<h2>Registered Users</h2>
<div class="table-responsive">