~homeworkprod/byceps

2ad53f37ca3eb7b80de8934f7cc4df4b9cc76583 — Jochen Kupperschmidt 5 months ago 1c559ff
Make `image_filename` argument to `update_brand` mandatory

Omitting the original keyword argument would remove an existing image
filename from the brand. This change should prevent that.
2 files changed, 2 insertions(+), 4 deletions(-)

M byceps/blueprints/admin/brand/views.py
M byceps/services/brand/service.py
M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +1 -3
@@ 134,9 134,7 @@ def update(brand_id):
    title = form.title.data.strip()
    image_filename = form.image_filename.data.strip() or None

    brand = brand_service.update_brand(
        brand.id, title, image_filename=image_filename
    )
    brand = brand_service.update_brand(brand.id, title, image_filename)

    flash_success(
        gettext('Brand "%(title)s" has been updated.', title=brand.title)

M byceps/services/brand/service.py => byceps/services/brand/service.py +1 -1
@@ 28,7 28,7 @@ def create_brand(brand_id: BrandID, title: str) -> Brand:


def update_brand(
    brand_id: BrandID, title: str, *, image_filename: Optional[str] = None
    brand_id: BrandID, title: str, image_filename: Optional[str]
) -> Brand:
    """Update a brand."""
    brand = _get_db_brand(brand_id)