user dashboard
This commit is contained in:
@@ -122,7 +122,11 @@ def dashboard():
|
|||||||
documents = {doc.user_id: doc for doc in Document.query.all()}
|
documents = {doc.user_id: doc for doc in Document.query.all()}
|
||||||
bookings = Booking.query.join(Listing).filter(Listing.host_id == current_user.id).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 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'])
|
@app.route('/create-listing', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block title %}User Dashboard{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="text-center">Your Bookings</h1>
|
||||||
|
{% if bookings %}
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<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.listing.title if booking.listing else 'Unknown' }}</td>
|
||||||
|
<td>{{ booking.listing.location if booking.listing else 'Unknown' }}</td>
|
||||||
|
<td>{{ booking.listing.PROPERTY_TYPES.get(booking.listing.property_type, 'Unknown') 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>
|
||||||
|
{% else %}
|
||||||
|
<p class="text-center">You have no bookings yet.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user