show all properties
This commit is contained in:
@@ -12,15 +12,10 @@ def load_user(user_id):
|
||||
@app.route('/')
|
||||
def home():
|
||||
property_type = request.args.get('property_type')
|
||||
listings = Listing.query
|
||||
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)
|
||||
listings = Listing.query.all()
|
||||
if property_type:
|
||||
available_listings = [l for l in available_listings if l.property_type == property_type]
|
||||
return render_template('index.html', listings=available_listings)
|
||||
listings = [l for l in listings if l.property_type == property_type]
|
||||
return render_template('index.html', listings=listings)
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
|
||||
Reference in New Issue
Block a user