Changeset 4b884dc in rattail


Ignore:
Timestamp:
02/19/19 20:13:44 (2 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
b4942c4b
Parents:
4da37f6
Message:

Add CustomerNote and Customer.notes

might as well take advantage of this notes table...

Location:
rattail/db/model
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rattail/db/model/__init__.py

    r4da37f6 r4b884dc  
    3434from .stores import Store, StorePhoneNumber, StoreEmailAddress
    3535from .customers import (Customer, CustomerPhoneNumber, CustomerEmailAddress, CustomerMailingAddress,
    36                         CustomerGroup, CustomerGroupAssignment, CustomerPerson)
     36                        CustomerGroup, CustomerGroupAssignment, CustomerPerson, CustomerNote)
    3737from .members import Member, MemberPhoneNumber, MemberEmailAddress, MemberMailingAddress
    3838
  • rattail/db/model/customers.py

    r4da37f6 r4b884dc  
    3434
    3535from rattail.db.model import Base, uuid_column, getset_factory
    36 from rattail.db.model import PhoneNumber, EmailAddress, MailingAddress, Person
     36from rattail.db.model import PhoneNumber, EmailAddress, MailingAddress, Person, Note
    3737
    3838
     
    202202
    203203
     204class CustomerNote(Note):
     205    """
     206    Represents a note attached to a customer.
     207    """
     208    __mapper_args__ = {'polymorphic_identity': 'Customer'}
     209
     210    customer = orm.relationship(
     211        Customer,
     212        primaryjoin='Customer.uuid == CustomerNote.parent_uuid',
     213        foreign_keys='CustomerNote.parent_uuid',
     214        doc="""
     215        Reference to the customer to which this note is attached.
     216        """,
     217        backref=orm.backref(
     218            'notes',
     219            primaryjoin='CustomerNote.parent_uuid == Customer.uuid',
     220            foreign_keys='CustomerNote.parent_uuid',
     221            order_by='CustomerNote.created',
     222            cascade='all, delete-orphan',
     223            doc="""
     224            Sequence of notes which belong to the customer.
     225            """))
     226
     227
    204228@six.python_2_unicode_compatible
    205229class CustomerGroup(Base):
Note: See TracChangeset for help on using the changeset viewer.