Cleanup attribute names for MemberInfo model

This commit is contained in:
Lance Edgar 2019-10-25 15:33:42 -05:00
parent dbfeb91868
commit a15b6eace2

View file

@ -440,7 +440,7 @@ class Customer(Base):
member_info = orm.relationship( member_info = orm.relationship(
'MemberInfo', 'MemberInfo',
primaryjoin='MemberInfo.card_no == Customer.card_number', primaryjoin='MemberInfo.card_number == Customer.card_number',
foreign_keys=[card_number], foreign_keys=[card_number],
uselist=False, uselist=False,
back_populates='customers', back_populates='customers',
@ -452,21 +452,22 @@ class Customer(Base):
return "{} {}".format(self.first_name or '', self.last_name or '').strip() return "{} {}".format(self.first_name or '', self.last_name or '').strip()
@six.python_2_unicode_compatible
class MemberInfo(Base): class MemberInfo(Base):
""" """
Contact info regarding a member of the organization. Contact info regarding a member of the organization.
""" """
__tablename__ = 'meminfo' __tablename__ = 'meminfo'
card_no = sa.Column(sa.Integer(), primary_key=True, autoincrement=False, nullable=False) card_number = sa.Column('card_no', sa.Integer(), primary_key=True, autoincrement=False, nullable=False)
last_name = sa.Column(sa.String(length=30), nullable=True) last_name = sa.Column(sa.String(length=30), nullable=True)
first_name = sa.Column(sa.String(length=30), nullable=True) first_name = sa.Column(sa.String(length=30), nullable=True)
othlast_name = sa.Column(sa.String(length=30), nullable=True) other_last_name = sa.Column('othlast_name', sa.String(length=30), nullable=True)
othfirst_name = sa.Column(sa.String(length=30), nullable=True) other_first_name = sa.Column('othfirst_name', sa.String(length=30), nullable=True)
street = sa.Column(sa.String(length=255), nullable=True) street = sa.Column(sa.String(length=255), nullable=True)
@ -478,15 +479,15 @@ class MemberInfo(Base):
phone = sa.Column(sa.String(length=30), nullable=True) phone = sa.Column(sa.String(length=30), nullable=True)
email_1 = sa.Column(sa.String(length=50), nullable=True) email = sa.Column('email_1', sa.String(length=50), nullable=True)
email_2 = sa.Column(sa.String(length=50), nullable=True) email2 = sa.Column('email_2', sa.String(length=50), nullable=True)
ads_OK = sa.Column(sa.Boolean(), nullable=True, default=True) ads_ok = sa.Column('ads_OK', sa.Boolean(), nullable=True, default=True)
customers = orm.relationship( customers = orm.relationship(
Customer, Customer,
primaryjoin=Customer.card_number == card_no, primaryjoin=Customer.card_number == card_number,
foreign_keys=[Customer.card_number], foreign_keys=[Customer.card_number],
back_populates='member_info', back_populates='member_info',
remote_side=Customer.card_number, remote_side=Customer.card_number,
@ -496,9 +497,9 @@ class MemberInfo(Base):
@property @property
def full_name(self): def full_name(self):
return '{0} {1}'.format(self.first_name or '', self.last_name or '').strip() return '{} {}'.format(self.first_name or '', self.last_name or '').strip()
def __unicode__(self): def __str__(self):
return self.full_name return self.full_name