[pricelist] fix bug set no volumes are set

This commit is contained in:
Tim Gröger 2021-04-15 15:23:37 +02:00
parent 32ad4471c6
commit 0630b5183d
1 changed files with 6 additions and 3 deletions

View File

@ -188,7 +188,8 @@ def update_drink(identifier, data):
if drink_type:
drink.type = drink_type
if volumes is not None and session.user_.has_permission(EDIT_VOLUME):
set_volumes(volumes, drink)
drink.volumes = []
drink.volumes = set_volumes(volumes)
if len(tags) > 0:
drink.tags = tags
db.session.commit()
@ -197,11 +198,13 @@ def update_drink(identifier, data):
raise BadRequest
def set_volumes(volumes, drink):
def set_volumes(volumes):
retVal = []
if not isinstance(volumes, list):
raise BadRequest
for volume in volumes:
drink.volumes.append(set_volume(volume))
retVal.append(set_volume(volume))
return retVal
def delete_drink(identifier):