Clean up Product model code a bit

This commit is contained in:
Lance Edgar 2016-12-14 22:05:29 -06:00
parent 874ba69813
commit 3d6ee12c0f
2 changed files with 49 additions and 54 deletions

View file

@ -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 ''

View file

@ -195,10 +195,11 @@ UTC timestamp of the product's last sale event.
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.