show all properties
This commit is contained in:
@@ -12,15 +12,10 @@ def load_user(user_id):
|
|||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home():
|
def home():
|
||||||
property_type = request.args.get('property_type')
|
property_type = request.args.get('property_type')
|
||||||
listings = Listing.query
|
listings = Listing.query.all()
|
||||||
available_listings = []
|
|
||||||
for listing in listings:
|
|
||||||
bookings = Booking.query.filter_by(listing_id=listing.id).all()
|
|
||||||
if all(datetime.strptime(booking.check_out, '%Y-%m-%d') < datetime.now() for booking in bookings):
|
|
||||||
available_listings.append(listing)
|
|
||||||
if property_type:
|
if property_type:
|
||||||
available_listings = [l for l in available_listings if l.property_type == property_type]
|
listings = [l for l in listings if l.property_type == property_type]
|
||||||
return render_template('index.html', listings=available_listings)
|
return render_template('index.html', listings=listings)
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
|
|||||||
Reference in New Issue
Block a user