Rename attributes for MemberType data model

also, comment-out the "sales code" column for now, since it doesn't exist in
all production databases.  (not sure how best to handle that yet)
This commit is contained in:
Lance Edgar 2019-07-23 10:55:42 -05:00
parent 08a062f654
commit d2e764f388

View file

@ -332,11 +332,11 @@ class MemberType(Base):
"""
__tablename__ = 'memtype'
memtype = sa.Column(sa.SmallInteger(), primary_key=True, nullable=False, default=0)
id = sa.Column('memtype', sa.SmallInteger(), primary_key=True, nullable=False, default=0)
memDesc = sa.Column(sa.String(length=20), nullable=True)
description = sa.Column('memDesc', sa.String(length=20), nullable=True)
custdataType = sa.Column(sa.String(length=10), nullable=True)
customer_type = sa.Column('custdataType', sa.String(length=10), nullable=True)
discount = sa.Column(sa.SmallInteger(), nullable=True)
@ -344,10 +344,12 @@ class MemberType(Base):
ssi = sa.Column(sa.Boolean(), nullable=True)
salesCode = sa.Column(sa.Integer(), nullable=True)
# TODO: this was apparently added "recently" - isn't present in all DBs
# (need to figure out how to conditionally include it in model?)
# sales_code = sa.Column('salesCode', sa.Integer(), nullable=True)
def __str__(self):
return self.memDesc or ""
return self.description or ""
class Customer(Base):
@ -404,7 +406,7 @@ class Customer(Base):
member_type = orm.relationship(
MemberType,
primaryjoin=MemberType.memtype == memType,
primaryjoin=MemberType.id == memType,
foreign_keys=[memType],
doc="""
Reference to the :class:`MemberType` to which this member belongs.