🛠️

- add show price preference(store in cookies)
This commit is contained in:
2026-06-12 17:36:57 +08:00
parent 3f386e5e38
commit 9e9788ea22
13 changed files with 320 additions and 18 deletions
+19
View File
@@ -0,0 +1,19 @@
VALID_PRICE_PREFS = ("total", "sqft", "both")
def get_price_pref(request) -> str:
pref = request.cookies.get("price_pref", "total")
if pref not in VALID_PRICE_PREFS:
pref = "total"
return pref
def format_price(value: int, price_pref: str = "total", area_sqft: int = 0) -> str:
if area_sqft > 0:
unit_price = round(value / area_sqft)
if price_pref == "sqft":
return f"${unit_price:,}/sqft"
if price_pref == "both":
return f"${value:,} (${unit_price:,}/sqft)"
return f"${value:,}"