Changeset 1b69309 in rattail


Ignore:
Timestamp:
07/24/2022 01:21:01 PM (6 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
e77ce7f
Parents:
780f781
Message:

Add primary flag for ContactMixin.add_email() and add_phone()

File:
1 edited

Legend:

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

    r780f781 r1b69309  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2021 Lance Edgar
     5#  Copyright © 2010-2022 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    196196        """
    197197        flush = kwargs.pop('flush', True)
     198        primary = kwargs.pop('primary', False)
    198199        email = self.make_email(**kwargs)
    199200        self.emails.append(email)
     
    201202            session = orm.object_session(self)
    202203            session.flush()
     204        if primary:
     205            self.set_primary_email(email, flush=flush)
    203206        return email
    204207
     
    263266        """
    264267        flush = kwargs.pop('flush', True)
     268        primary = kwargs.pop('primary', False)
    265269        phone = self.make_phone(**kwargs)
    266270        self.phones.append(phone)
     
    268272            session = orm.object_session(self)
    269273            session.flush()
     274        if primary:
     275            self.set_primary_phone(phone, flush=flush)
    270276        return phone
    271277
Note: See TracChangeset for help on using the changeset viewer.