♑🛠️
- add show price preference(store in cookies)
This commit is contained in:
+16
-2
@@ -52,9 +52,17 @@ async def property_list(request: Request, db: Session = Depends(get_db)):
|
||||
if prop_type:
|
||||
query = query.filter(Property.property_type == prop_type)
|
||||
if min_price:
|
||||
query = query.filter(Property.price >= int(min_price))
|
||||
min_val = int(min_price)
|
||||
if request.state.price_pref == "sqft":
|
||||
query = query.filter(Property.price >= min_val * Property.area_sqft)
|
||||
else:
|
||||
query = query.filter(Property.price >= min_val)
|
||||
if max_price:
|
||||
query = query.filter(Property.price <= int(max_price))
|
||||
max_val = int(max_price)
|
||||
if request.state.price_pref == "sqft":
|
||||
query = query.filter(Property.price <= max_val * Property.area_sqft)
|
||||
else:
|
||||
query = query.filter(Property.price <= max_val)
|
||||
if bedrooms:
|
||||
query = query.filter(Property.bedrooms >= int(bedrooms))
|
||||
if city:
|
||||
@@ -91,6 +99,7 @@ async def property_list(request: Request, db: Session = Depends(get_db)):
|
||||
"bedrooms": bedrooms,
|
||||
"city_filter": city,
|
||||
"state_filter": state,
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
|
||||
@@ -102,6 +111,7 @@ async def property_create_form(request: Request, db: Session = Depends(get_db)):
|
||||
return templates.TemplateResponse(request, "properties/create.html", {
|
||||
"user": user,
|
||||
"values": {},
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
|
||||
@@ -154,6 +164,7 @@ async def property_create_submit(
|
||||
"user": user,
|
||||
"values": {k: v for k, v in request._form.items()} if hasattr(request, '_form') else {},
|
||||
"error": "Please provide at least one contact method (email or phone).",
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
prop = Property(
|
||||
@@ -211,6 +222,7 @@ async def property_detail(prop_id: int, request: Request, db: Session = Depends(
|
||||
"primary_image": primary_image,
|
||||
"images": images,
|
||||
"is_favorited": is_favorited,
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
|
||||
@@ -231,6 +243,7 @@ async def property_edit_form(prop_id: int, request: Request, db: Session = Depen
|
||||
"user": user,
|
||||
"prop": prop,
|
||||
"primary_image": primary_image,
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
|
||||
@@ -365,4 +378,5 @@ async def dashboard(request: Request, db: Session = Depends(get_db)):
|
||||
"user": user,
|
||||
"my_properties": my_properties,
|
||||
"favorites": favorites,
|
||||
"price_pref": request.state.price_pref,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user