diff --git a/tailbone/views/master.py b/tailbone/views/master.py index e30598bc..ae38f2b9 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -1154,27 +1154,20 @@ class MasterView(View): alternative. """ obj = self.get_instance() - change = self.touch_instance(obj) + self.touch_instance(obj) self.request.session.flash("{} has been touched: {}".format( self.get_model_title(), self.get_instance_title(obj))) return self.redirect(self.get_action_url('view', obj)) def touch_instance(self, obj): """ - Perform actual "touch" logic for the given object. Must return the - :class:`rattail:~rattail.db.model.Change` record involved. - - .. todo:: - Why should this return the change object? We're not using it for - anything (yet?) but some views may generate multiple changes when - touching the primary object, i.e. touch related objects also. + Perform actual "touch" logic for the given object. """ change = model.Change() change.class_name = obj.__class__.__name__ change.instance_uuid = obj.uuid change = self.Session.merge(change) change.deleted = False - return change def versions(self): """ diff --git a/tailbone/views/people.py b/tailbone/views/people.py index c1eb2dfb..88612d97 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -146,6 +146,35 @@ class PeopleView(MasterView): return not bool(person.user and person.user.username == 'chuck') return True + def touch_instance(self, person): + """ + Supplements the default logic as follows: + + In addition to "touching" the person proper, we also "touch" each + contact info record associated with them. + """ + # touch person, as per usual + super(PeopleView, self).touch_instance(person) + + def touch(obj): + change = model.Change() + change.class_name = obj.__class__.__name__ + change.instance_uuid = obj.uuid + change.deleted = False + self.Session.add(change) + + # phone numbers + for phone in person.phones: + touch(phone) + + # email addresses + for email in person.emails: + touch(email) + + # mailing addresses + for address in person.addresses: + touch(address) + def configure_common_form(self, f): super(PeopleView, self).configure_common_form(f)