diff --git a/routes.py b/routes.py index 0cd9aac..0800d74 100644 --- a/routes.py +++ b/routes.py @@ -122,7 +122,11 @@ def dashboard(): documents = {doc.user_id: doc for doc in Document.query.all()} 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')) + else: + bookings = Booking.query.filter_by(user_id=current_user.id).join(Listing).add_columns( + Listing.title, Listing.location, Listing.property_type, Booking.check_in, Booking.check_out + ).all() + return render_template('user.html', bookings=bookings) @app.route('/create-listing', methods=['GET', 'POST']) @login_required diff --git a/templates/user.html b/templates/user.html new file mode 100644 index 0000000..fd89f53 --- /dev/null +++ b/templates/user.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} +{% block title %}User Dashboard{% endblock %} + +{% block content %} +
| Listing | +Location | +Property Type | +Check-in | +Check-out | +
|---|---|---|---|---|
| {{ booking.listing.title if booking.listing else 'Unknown' }} | +{{ booking.listing.location if booking.listing else 'Unknown' }} | +{{ booking.listing.PROPERTY_TYPES.get(booking.listing.property_type, 'Unknown') if booking.listing else 'Unknown' }} | +{{ booking.check_in.strftime('%Y-%m-%d') }} | +{{ booking.check_out.strftime('%Y-%m-%d') }} | +
You have no bookings yet.
+ {% endif %} +