From ef1a25f0dc269cc39250c69d17b2b8a38e64c38b Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 30 Jul 2020 11:11:17 -0500 Subject: [PATCH] Make sure `MemberInfo.customers` is sorted by person number also improve the str() method a bit --- corepos/db/office_op/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 6374624..4026d8a 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -1017,6 +1017,7 @@ class MemberInfo(Base): customers = orm.relationship( CustData, primaryjoin=CustData.card_number == card_number, + order_by=CustData.person_number, foreign_keys=[CustData.card_number], back_populates='member_info', remote_side=CustData.card_number, @@ -1073,7 +1074,10 @@ class MemberInfo(Base): return '{} {}'.format(self.first_name or '', self.last_name or '').strip() def __str__(self): - return self.full_name + name = self.full_name + if name: + return name + return "Member Info #{}".format(self.card_number) def split_street(self): """