Add MemberDate and MemberContact models to schema
This commit is contained in:
parent
a15b6eace2
commit
9ae1a04cad
|
@ -495,6 +495,20 @@ class MemberInfo(Base):
|
|||
List of :class:`Customer` instances which are associated with this member info.
|
||||
""")
|
||||
|
||||
dates = orm.relationship(
|
||||
'MemberDate',
|
||||
primaryjoin='MemberDate.card_number == MemberInfo.card_number',
|
||||
foreign_keys='MemberDate.card_number',
|
||||
cascade='all, delete-orphan',
|
||||
doc="""
|
||||
List of date records for the member.
|
||||
""",
|
||||
backref=orm.backref(
|
||||
'member',
|
||||
doc="""
|
||||
Reference to the member to whom the date record applies.
|
||||
"""))
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
return '{} {}'.format(self.first_name or '', self.last_name or '').strip()
|
||||
|
@ -503,6 +517,55 @@ class MemberInfo(Base):
|
|||
return self.full_name
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class MemberDate(Base):
|
||||
"""
|
||||
Join/exit dates for members
|
||||
"""
|
||||
__tablename__ = 'memDates'
|
||||
|
||||
card_number = sa.Column('card_no', sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
|
||||
|
||||
start_date = sa.Column(sa.DateTime(), nullable=True)
|
||||
|
||||
end_date = sa.Column(sa.DateTime(), nullable=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{} thru {}".format(
|
||||
self.start_date.date() if self.start_date else "??",
|
||||
self.end_date.date() if self.end_date else "??")
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class MemberContact(Base):
|
||||
"""
|
||||
Contact preferences for members
|
||||
"""
|
||||
__tablename__ = 'memContact'
|
||||
|
||||
card_number = sa.Column('card_no', sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
|
||||
|
||||
preference = sa.Column('pref', sa.Integer(), nullable=True)
|
||||
|
||||
member = orm.relationship(
|
||||
MemberInfo,
|
||||
primaryjoin=MemberInfo.card_number == card_number,
|
||||
foreign_keys=[MemberInfo.card_number],
|
||||
uselist=False,
|
||||
doc="""
|
||||
Reference to the member to whom the contact record applies.
|
||||
""",
|
||||
backref=orm.backref(
|
||||
'contact',
|
||||
uselist=False,
|
||||
doc="""
|
||||
Reference to contact preference record for the member.
|
||||
"""))
|
||||
|
||||
def __str__(self):
|
||||
return str(self.preference)
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class HouseCoupon(Base):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue