Changeset 721dadc in rattail


Ignore:
Timestamp:
08/03/2022 11:12:44 AM (6 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
68b3011
Parents:
3a7d5a6
Message:

Add "touch" logic for employee handler

Location:
rattail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • rattail/app.py

    r3a7d5a6 r721dadc  
    245245            session.delete(setting)
    246246
     247    def touch_object(self, session, obj):
     248        """
     249        Mark the given object as having been changed, such that the
     250        datasync will pick it up and propagate the object to other
     251        nodes.
     252
     253        Note that this is *minimal* logic; only the given object will
     254        be "touched" in this way, i.e. no related records will be
     255        touched.  So if those also need it, you must call this method
     256        for each related object separately.
     257        """
     258        model = self.model
     259        change = model.Change()
     260        change.class_name = obj.__class__.__name__
     261        change.instance_uuid = obj.uuid
     262        change = session.merge(change)
     263        change.deleted = False
     264
    247265    def get_active_stores(self, session, **kwargs):
    248266        """
  • rattail/employment.py

    r3a7d5a6 r721dadc  
    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.
     
    3737    Base class and default implementation for employment handlers.
    3838    """
     39
     40    def touch_employee(self, session, employee):
     41        self.app.touch_object(session, employee)
     42        self.app.touch_object(session, employee.person)
     43
     44        for email in employee.emails:
     45            self.app.touch_object(session, email)
     46
     47        for phone in employee.phones:
     48            self.app.touch_object(session, phone)
     49
     50        for store in employee._stores:
     51            self.app.touch_object(session, store)
     52
     53        for department in employee._departments:
     54            self.app.touch_object(session, department)
    3955
    4056    def begin_employment(self, person, start_date, **kwargs):
Note: See TracChangeset for help on using the changeset viewer.