Clean up Product
model code a bit
This commit is contained in:
parent
874ba69813
commit
3d6ee12c0f
|
@ -106,11 +106,6 @@ class Family(Base):
|
||||||
code = sa.Column(sa.Integer())
|
code = sa.Column(sa.Integer())
|
||||||
name = sa.Column(sa.String(length=50))
|
name = sa.Column(sa.String(length=50))
|
||||||
|
|
||||||
products = relationship(
|
|
||||||
u'Product', back_populates=u'family', doc=u"""\
|
|
||||||
Collection of :class:`Product` instances which associate with this family.
|
|
||||||
""")
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return unicode(self.name or '')
|
return unicode(self.name or '')
|
||||||
|
|
||||||
|
@ -129,11 +124,6 @@ class ReportCode(Base):
|
||||||
code = sa.Column(sa.Integer(), nullable=False)
|
code = sa.Column(sa.Integer(), nullable=False)
|
||||||
name = sa.Column(sa.String(length=100), nullable=True)
|
name = sa.Column(sa.String(length=100), nullable=True)
|
||||||
|
|
||||||
products = relationship(
|
|
||||||
u'Product', back_populates=u'report_code', doc=u"""\
|
|
||||||
Collection of :class:`Product` instances which associate with this report code.
|
|
||||||
""")
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
if not self.code:
|
if not self.code:
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -88,7 +88,7 @@ class Product(Base):
|
||||||
sa.ForeignKeyConstraint(['regular_price_uuid'], ['product_price.uuid'], name='product_fk_regular_price', use_alter=True),
|
sa.ForeignKeyConstraint(['regular_price_uuid'], ['product_price.uuid'], name='product_fk_regular_price', use_alter=True),
|
||||||
sa.ForeignKeyConstraint(['current_price_uuid'], ['product_price.uuid'], name='product_fk_current_price', use_alter=True),
|
sa.ForeignKeyConstraint(['current_price_uuid'], ['product_price.uuid'], name='product_fk_current_price', use_alter=True),
|
||||||
sa.Index('product_ix_upc', 'upc'),
|
sa.Index('product_ix_upc', 'upc'),
|
||||||
)
|
)
|
||||||
__versioned__ = {}
|
__versioned__ = {}
|
||||||
|
|
||||||
uuid = uuid_column()
|
uuid = uuid_column()
|
||||||
|
@ -103,22 +103,22 @@ class Product(Base):
|
||||||
""")
|
""")
|
||||||
|
|
||||||
deposit_link_uuid = sa.Column(sa.String(length=32), nullable=True, doc="""
|
deposit_link_uuid = sa.Column(sa.String(length=32), nullable=True, doc="""
|
||||||
UUID of the product's deposit link, if any.
|
UUID of the product's deposit link, if any.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
deposit_link = orm.relationship('DepositLink', doc="""
|
deposit_link = orm.relationship('DepositLink', doc="""
|
||||||
Reference to the :class:`DepositLink` instance with which the product
|
Reference to the :class:`DepositLink` instance with which the product
|
||||||
associates, if any.
|
associates, if any.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
tax_uuid = sa.Column(sa.String(length=32), nullable=True, doc="""
|
tax_uuid = sa.Column(sa.String(length=32), nullable=True, doc="""
|
||||||
UUID of the product's tax, if any.
|
UUID of the product's tax, if any.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
tax = orm.relationship(Tax, doc="""
|
tax = orm.relationship(Tax, doc="""
|
||||||
Reference to the :class:`Tax` instance with which the product associates, if
|
Reference to the :class:`Tax` instance with which the product associates, if
|
||||||
any.
|
any.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
brand_uuid = sa.Column(sa.String(length=32))
|
brand_uuid = sa.Column(sa.String(length=32))
|
||||||
description = sa.Column(sa.String(length=60))
|
description = sa.Column(sa.String(length=60))
|
||||||
|
@ -126,49 +126,49 @@ any.
|
||||||
size = sa.Column(sa.String(length=30))
|
size = sa.Column(sa.String(length=30))
|
||||||
|
|
||||||
unit_size = sa.Column(sa.Numeric(precision=8, scale=3), nullable=True, doc="""
|
unit_size = sa.Column(sa.Numeric(precision=8, scale=3), nullable=True, doc="""
|
||||||
Unit size for product, as decimal. This refers to the numeric size of a unit
|
Unit size for product, as decimal. This refers to the numeric size of a unit
|
||||||
of the product, in terms of the :attr:`unit_of_measure`, and may be used for
|
of the product, in terms of the :attr:`unit_of_measure`, and may be used for
|
||||||
smarter price comparisons etc.
|
smarter price comparisons etc.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
unit_of_measure = sa.Column(sa.String(length=4), nullable=False,
|
unit_of_measure = sa.Column(sa.String(length=4), nullable=False,
|
||||||
default=enum.UNIT_OF_MEASURE_NONE, doc="""
|
default=enum.UNIT_OF_MEASURE_NONE, doc="""
|
||||||
Code indicating the unit of measure for the product. Value should be one of
|
Code indicating the unit of measure for the product. Value should be one of
|
||||||
the keys of the ``rattail.enum.UNIT_OF_MEASURE`` dictionary.
|
the keys of the ``rattail.enum.UNIT_OF_MEASURE`` dictionary.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
weighed = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
weighed = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
||||||
Whether or not the product must be weighed to determine its final price.
|
Whether or not the product must be weighed to determine its final price.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
case_pack = sa.Column(sa.Integer(), nullable=True, doc="""
|
case_pack = sa.Column(sa.Integer(), nullable=True, doc="""
|
||||||
Pack size for the product, i.e. how many units are in a case.
|
Pack size for the product, i.e. how many units are in a case.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
organic = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
organic = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
||||||
Whether the item is organic.
|
Whether the item is organic.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
not_for_sale = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
not_for_sale = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
||||||
Flag to indicate items which are not available for sale.
|
Flag to indicate items which are not available for sale.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
deleted = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
deleted = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
||||||
Flag to indicate items which have been deleted. Obviously this is implies
|
Flag to indicate items which have been deleted. Obviously this is implies
|
||||||
"false" deletion, where the record is actually kept on file. Whether or not
|
"false" deletion, where the record is actually kept on file. Whether or not
|
||||||
you use this is up to you.
|
you use this is up to you.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
regular_price_uuid = sa.Column(sa.String(length=32))
|
regular_price_uuid = sa.Column(sa.String(length=32))
|
||||||
current_price_uuid = sa.Column(sa.String(length=32))
|
current_price_uuid = sa.Column(sa.String(length=32))
|
||||||
|
|
||||||
discountable = sa.Column(sa.Boolean(), nullable=False, default=True, doc="""
|
discountable = sa.Column(sa.Boolean(), nullable=False, default=True, doc="""
|
||||||
Whether or not the product may be discounted in any way.
|
Whether or not the product may be discounted in any way.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
special_order = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
special_order = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
|
||||||
Whether the product is available for special order.
|
Whether the product is available for special order.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
food_stampable = sa.Column(sa.Boolean(), nullable=True, doc="""
|
food_stampable = sa.Column(sa.Boolean(), nullable=True, doc="""
|
||||||
Flag indicating whether food stamps are a valid form of payment for the item.
|
Flag indicating whether food stamps are a valid form of payment for the item.
|
||||||
|
@ -187,18 +187,19 @@ Whether the product is available for special order.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
last_sold = sa.Column(sa.DateTime(), nullable=True, doc="""
|
last_sold = sa.Column(sa.DateTime(), nullable=True, doc="""
|
||||||
UTC timestamp of the product's last sale event.
|
UTC timestamp of the product's last sale event.
|
||||||
""")
|
""")
|
||||||
|
|
||||||
department = orm.relationship(Department, order_by=Department.name)
|
department = orm.relationship(Department, order_by=Department.name)
|
||||||
|
|
||||||
subdepartment = orm.relationship(
|
subdepartment = orm.relationship(
|
||||||
Subdepartment,
|
Subdepartment,
|
||||||
order_by=Subdepartment.name,
|
order_by=Subdepartment.name,
|
||||||
backref=orm.backref('products', cascade='all'))
|
backref=orm.backref('products'))
|
||||||
|
|
||||||
category = orm.relationship(
|
category = orm.relationship(
|
||||||
Category, back_populates='products')
|
Category,
|
||||||
|
backref=orm.backref('products'))
|
||||||
|
|
||||||
brand = orm.relationship(Brand)
|
brand = orm.relationship(Brand)
|
||||||
|
|
||||||
|
@ -208,7 +209,11 @@ UTC timestamp of the product's last sale event.
|
||||||
Reference to the :class:`Family` instance with which the product
|
Reference to the :class:`Family` instance with which the product
|
||||||
associates, if any.
|
associates, if any.
|
||||||
""",
|
""",
|
||||||
back_populates='products')
|
backref=orm.backref(
|
||||||
|
'products',
|
||||||
|
doc="""
|
||||||
|
List of :class:`Product` objects which belong to this family.
|
||||||
|
"""))
|
||||||
|
|
||||||
report_code = orm.relationship(
|
report_code = orm.relationship(
|
||||||
'ReportCode',
|
'ReportCode',
|
||||||
|
@ -216,7 +221,11 @@ UTC timestamp of the product's last sale event.
|
||||||
Reference to the :class:`ReportCode` instance with which the product
|
Reference to the :class:`ReportCode` instance with which the product
|
||||||
associates, if any.
|
associates, if any.
|
||||||
""",
|
""",
|
||||||
back_populates='products')
|
backref=orm.backref(
|
||||||
|
'products',
|
||||||
|
doc="""
|
||||||
|
List of :class:`Product` objects which associate with this report code.
|
||||||
|
"""))
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.full_description
|
return self.full_description
|
||||||
|
@ -250,10 +259,6 @@ UTC timestamp of the product's last sale event.
|
||||||
return cost
|
return cost
|
||||||
|
|
||||||
|
|
||||||
Category.products = orm.relationship(
|
|
||||||
Product, back_populates='category')
|
|
||||||
|
|
||||||
|
|
||||||
class ProductCode(Base):
|
class ProductCode(Base):
|
||||||
"""
|
"""
|
||||||
Represents an arbitrary "code" for a product.
|
Represents an arbitrary "code" for a product.
|
||||||
|
|
Loading…
Reference in a new issue