Add split_street()
method for MemberInfo
This commit is contained in:
parent
13b8380527
commit
365d679d76
|
@ -24,12 +24,16 @@
|
|||
Data model for CORE POS "office_op" DB
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.ext.associationproxy import association_proxy
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
|
@ -1056,6 +1060,23 @@ class MemberInfo(Base):
|
|||
def __str__(self):
|
||||
return self.full_name
|
||||
|
||||
def split_street(self):
|
||||
"""
|
||||
Tries to split the :attr:`street` attribute into 2 separate lines, e.g.
|
||||
"street1" and "street2" style. Always returns a 2-tuple even if the
|
||||
second line would be empty.
|
||||
"""
|
||||
address = (self.street or '').strip()
|
||||
lines = address.split('\n')
|
||||
street1 = lines[0].strip() or None
|
||||
street2 = None
|
||||
if len(lines) > 1:
|
||||
street2 = lines[1].strip() or None
|
||||
if len(lines) > 2:
|
||||
log.warning("member #%s has %s address lines: %s",
|
||||
self.card_number, len(lines), self)
|
||||
return (street1, street2)
|
||||
|
||||
|
||||
class MemberDate(Base):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue