P5-4794 optimize listprice code and fix wallpaper listprice

This commit is contained in:
Martin Carlsson
2020-02-07 13:04:54 +01:00
committed by GitHub
parent 2f4275e66a
commit 6184328d6c
2 changed files with 6 additions and 12 deletions
+5 -7
View File
@@ -512,15 +512,13 @@ def inquiry(inquiry_id):
@mod.route("/list-prices/<string:territory>/wallpaper")
def list_prices_wallpaper(territory):
wallpapers = PrintProduct.query.wallpapers().with_relations().all()
wallpapers = PrintProduct.query.wallpapers().all()
result = {}
material = Material.query.filter(Material.name == "standard-wallpaper").one()
market = market_model.from_territory(territory)
for wallpaper in wallpapers:
result[wallpaper.id] = wallpaper_price(
width=100,
height=100,
result[wallpaper.id] = m2_price(
material=material,
market=market,
designer=wallpaper.product.designer,
@@ -530,7 +528,7 @@ def list_prices_wallpaper(territory):
@mod.route("/list-prices/<string:territory>/canvas")
def list_prices_canvas(territory):
canvases = PrintProduct.query.canvases().with_relations().all()
canvases = PrintProduct.query.canvases().all()
market = market_model.from_territory(territory)
result = {}
@@ -547,7 +545,7 @@ def list_prices_canvas(territory):
@mod.route("/list-prices/<string:territory>/poster")
def list_prices_posters(territory):
posters = PrintProduct.query.posters().with_relations().all()
posters = PrintProduct.query.posters().all()
market = market_model.from_territory(territory)
result = {}
@@ -564,7 +562,7 @@ def list_prices_posters(territory):
@mod.route("/list-prices/<string:territory>/framed-print")
def list_prices_framed_prints(territory):
framed_prints = PrintProduct.query.framed_prints().with_relations().all()
framed_prints = PrintProduct.query.framed_prints().all()
market = market_model.from_territory(territory)
result = {}