mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Rename Product.weight to Product.unit
This commit is contained in:
parent
5c12463bf7
commit
d2cb557f8a
2 changed files with 4 additions and 5 deletions
|
@ -48,7 +48,6 @@ class Base:
|
||||||
try:
|
try:
|
||||||
setattr(self, name, self.cast(type_, value))
|
setattr(self, name, self.cast(type_, value))
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
raise
|
|
||||||
raise ValueError(f"Wrong value for field `{name}`: `{value}`")
|
raise ValueError(f"Wrong value for field `{name}`: `{value}`")
|
||||||
|
|
||||||
def cast(self, type, value):
|
def cast(self, type, value):
|
||||||
|
@ -92,7 +91,7 @@ class Product(Base):
|
||||||
name: str
|
name: str
|
||||||
ref: str
|
ref: str
|
||||||
price: price_field
|
price: price_field
|
||||||
weight: str = ""
|
unit: str = ""
|
||||||
description: str = ""
|
description: str = ""
|
||||||
url: str = ""
|
url: str = ""
|
||||||
img: str = ""
|
img: str = ""
|
||||||
|
@ -100,8 +99,8 @@ class Product(Base):
|
||||||
@property
|
@property
|
||||||
def label(self):
|
def label(self):
|
||||||
out = self.name
|
out = self.name
|
||||||
if self.weight:
|
if self.unit:
|
||||||
out += f" ({self.weight})"
|
out += f" ({self.unit})"
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,6 @@ async def test_export_products(client, delivery):
|
||||||
resp = await client.get(f"/livraison/{delivery.id}/exporter/produits")
|
resp = await client.get(f"/livraison/{delivery.id}/exporter/produits")
|
||||||
wb = load_workbook(filename=BytesIO(resp.body))
|
wb = load_workbook(filename=BytesIO(resp.body))
|
||||||
assert list(wb.active.values) == [
|
assert list(wb.active.values) == [
|
||||||
("name", "ref", "price", "weight", "description", "url", "img"),
|
("name", "ref", "price", "unit", "description", "url", "img"),
|
||||||
("Lait", "123", 1.5, None, None, None, None),
|
("Lait", "123", 1.5, None, None, None, None),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue