Add the Product.complete_size
convenience attribute
also define `str(VendorItem)`
This commit is contained in:
parent
7cf4ec1295
commit
b40fbf7cab
|
@ -611,6 +611,18 @@ class Product(Base):
|
||||||
fields = filter(bool, fields)
|
fields = filter(bool, fields)
|
||||||
return ' '.join(fields)
|
return ' '.join(fields)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def complete_size(self):
|
||||||
|
"""
|
||||||
|
Returns the "complete" size string for the product. This is based on
|
||||||
|
the :attr:`size` and :attr:`unit_of_measure` attributes.
|
||||||
|
"""
|
||||||
|
parts = [self.size, self.unit_of_measure]
|
||||||
|
parts = [(part or '').strip()
|
||||||
|
for part in parts]
|
||||||
|
parts = [part for part in parts if part]
|
||||||
|
return " ".join(parts).strip()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.description or ''
|
return self.description or ''
|
||||||
|
|
||||||
|
@ -771,6 +783,9 @@ class VendorItem(Base):
|
||||||
|
|
||||||
modified = sa.Column(sa.DateTime(), nullable=True)
|
modified = sa.Column(sa.DateTime(), nullable=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "{} from {}".format(self.sku, self.vendor)
|
||||||
|
|
||||||
|
|
||||||
class ScaleItem(Base):
|
class ScaleItem(Base):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue