diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 6677e98..a4da4fc 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -1179,6 +1179,21 @@ class MemberInfo(Base): Reference to the member to whom the date record applies. """)) + barcodes = orm.relationship( + 'MemberBarcode', + primaryjoin='MemberBarcode.card_number == MemberInfo.card_number', + foreign_keys='MemberBarcode.card_number', + order_by='MemberBarcode.upc', + # cascade='all, delete-orphan', + doc=""" + List of extra barcode records for the member. + """, + backref=orm.backref( + 'member_info', + doc=""" + Reference to the :class:`MemberInfo` record to which the barcode applies. + """)) + notes = orm.relationship( 'MemberNote', primaryjoin='MemberNote.card_number == MemberInfo.card_number', @@ -1284,6 +1299,21 @@ class MemberContact(Base): return str(self.preference) +class MemberBarcode(Base): + """ + Additional barcode for a member. + """ + __tablename__ = 'memberCards' + + card_number = sa.Column('card_no', sa.Integer(), nullable=False, + primary_key=True, autoincrement=False) + + upc = sa.Column(sa.String(length=13), nullable=False, primary_key=True) + + def __str__(self): + return self.upc or "" + + class MemberNote(Base): """ Additional notes for a member.