feature/pricelist #15
|
@ -221,6 +221,7 @@ def get_drinks(identifier=None):
|
||||||
search_name = request.args.get("search_name")
|
search_name = request.args.get("search_name")
|
||||||
search_key = request.args.get("search_key")
|
search_key = request.args.get("search_key")
|
||||||
ingredient = request.args.get("ingredient", type=bool)
|
ingredient = request.args.get("ingredient", type=bool)
|
||||||
|
receipt = request.args.get("receipt", type=bool)
|
||||||
try:
|
try:
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
limit = int(limit)
|
limit = int(limit)
|
||||||
|
@ -228,6 +229,8 @@ def get_drinks(identifier=None):
|
||||||
offset = int(offset)
|
offset = int(offset)
|
||||||
if ingredient is not None:
|
if ingredient is not None:
|
||||||
ingredient = bool(ingredient)
|
ingredient = bool(ingredient)
|
||||||
|
if receipt is not None:
|
||||||
|
receipt = bool(receipt)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise BadRequest
|
raise BadRequest
|
||||||
drinks, count = pricelist_controller.get_drinks(
|
drinks, count = pricelist_controller.get_drinks(
|
||||||
|
@ -237,6 +240,7 @@ def get_drinks(identifier=None):
|
||||||
search_name=search_name,
|
search_name=search_name,
|
||||||
search_key=search_key,
|
search_key=search_key,
|
||||||
ingredient=ingredient,
|
ingredient=ingredient,
|
||||||
|
receipt=receipt,
|
||||||
)
|
)
|
||||||
logger.debug(f"GET drink {drinks}, {count}")
|
logger.debug(f"GET drink {drinks}, {count}")
|
||||||
# return jsonify({"drinks": drinks, "count": count})
|
# return jsonify({"drinks": drinks, "count": count})
|
||||||
|
|
|
@ -131,7 +131,9 @@ def _create_public_drink(drink):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_drinks(name=None, public=False, limit=None, offset=None, search_name=None, search_key=None, ingredient=False):
|
def get_drinks(
|
||||||
|
name=None, public=False, limit=None, offset=None, search_name=None, search_key=None, ingredient=False, receipt=None
|
||||||
|
):
|
||||||
count = None
|
count = None
|
||||||
if name:
|
if name:
|
||||||
query = Drink.query.filter(Drink.name.contains(name))
|
query = Drink.query.filter(Drink.name.contains(name))
|
||||||
|
@ -139,6 +141,8 @@ def get_drinks(name=None, public=False, limit=None, offset=None, search_name=Non
|
||||||
query = Drink.query
|
query = Drink.query
|
||||||
if ingredient:
|
if ingredient:
|
||||||
query = query.filter(Drink.cost_per_volume >= 0)
|
query = query.filter(Drink.cost_per_volume >= 0)
|
||||||
|
if receipt:
|
||||||
|
query = query.filter(Drink.volumes.any(DrinkPriceVolume.ingredients != None))
|
||||||
if search_name:
|
if search_name:
|
||||||
if search_key == "name":
|
if search_key == "name":
|
||||||
query = query.filter(Drink.name.contains(search_name))
|
query = query.filter(Drink.name.contains(search_name))
|
||||||
|
|
Loading…
Reference in New Issue