view listing

This commit is contained in:
2025-01-20 17:51:42 +08:00
parent 628c2b6496
commit 424bb885ca
2 changed files with 26 additions and 0 deletions
+5
View File
@@ -115,3 +115,8 @@ def booking(listing_id):
db.session.commit()
return redirect(url_for('home'))
return render_template('booking.html', listing=listing, unavailable_dates=unavailable_dates)
@app.route('/view/<int:listing_id>', methods=['GET'])
def view_listing(listing_id):
listing = Listing.query.get_or_404(listing_id)
return render_template('view.html', listing=listing)
+21
View File
@@ -0,0 +1,21 @@
{% extends 'base.html' %}
{% block title %}View Listing{% endblock %}
{% block content %}
<div class="container mt-4">
<h1 class="text-center">{{ listing.title }}</h1>
{% if listing.images|length > 0 %}
<img src="{{ listing.images[0].url }}" class="img-fluid mb-4">
{% endif %}
<p><strong>Description:</strong> {{ listing.description }}</p>
<p><strong>Price:</strong> ${{ listing.price }}</p>
<p><strong>Location:</strong> {{ listing.location }}</p>
<p><strong>Property Type:</strong> {{ listing.property_type }}</p>
<p><strong>Max Guests:</strong> {{ listing.guests }}</p>
<p><strong>Rooms:</strong> {{ listing.rooms }}</p>
<p><strong>Bathrooms:</strong> {{ listing.bathrooms }}</p>
<p><strong>Beds:</strong> {{ listing.beds }}</p>
<a href="/booking/{{ listing.id }}" class="btn btn-primary mt-3">Book This Listing</a>
</div>
{% endblock %}