Add MemberNote
and MemberInfo.notes
to data model
This commit is contained in:
parent
beb73dc668
commit
07291b3fa7
|
@ -1024,6 +1024,21 @@ class MemberInfo(Base):
|
|||
Reference to the member to whom the date record applies.
|
||||
"""))
|
||||
|
||||
notes = orm.relationship(
|
||||
'MemberNote',
|
||||
primaryjoin='MemberNote.card_number == MemberInfo.card_number',
|
||||
foreign_keys='MemberNote.card_number',
|
||||
order_by='MemberNote.timestamp',
|
||||
cascade='all, delete-orphan',
|
||||
doc="""
|
||||
List of note records for the member.
|
||||
""",
|
||||
backref=orm.backref(
|
||||
'member_info',
|
||||
doc="""
|
||||
Reference to the :class:`MemberInfo` record to which the note applies.
|
||||
"""))
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
return '{} {}'.format(self.first_name or '', self.last_name or '').strip()
|
||||
|
@ -1079,6 +1094,26 @@ class MemberContact(Base):
|
|||
return str(self.preference)
|
||||
|
||||
|
||||
class MemberNote(Base):
|
||||
"""
|
||||
Additional notes for a member.
|
||||
"""
|
||||
__tablename__ = 'memberNotes'
|
||||
|
||||
id = sa.Column('memberNoteID', sa.Integer(), nullable=False, primary_key=True, autoincrement=True)
|
||||
|
||||
card_number = sa.Column('cardno', sa.Integer(), nullable=True)
|
||||
|
||||
note = sa.Column(sa.Text(), nullable=True)
|
||||
|
||||
timestamp = sa.Column('stamp', sa.DateTime(), nullable=True)
|
||||
|
||||
username = sa.Column(sa.String(length=50), nullable=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.note or ""
|
||||
|
||||
|
||||
class HouseCoupon(Base):
|
||||
"""
|
||||
Represents a "house" (store) coupon.
|
||||
|
|
Loading…
Reference in a new issue