Include version history for CustomerShopper, in profile view

This commit is contained in:
Lance Edgar 2023-06-10 21:09:35 -05:00
parent 9e1b83cbbe
commit f1a8b8df7f

View file

@ -1114,19 +1114,33 @@ class PersonView(MasterView):
.filter(cls.parent_uuid == person.uuid) .filter(cls.parent_uuid == person.uuid)
versions.extend(query.all()) versions.extend(query.all())
# CustomerPerson # Customer (account_holder)
cls = continuum.version_class(model.CustomerPerson) cls = continuum.version_class(model.Customer)
query = self.Session.query(cls)\ query = self.Session.query(cls)\
.filter(cls.person_uuid == person.uuid) .filter(cls.account_holder_uuid == person.uuid)
versions.extend(query.all()) versions.extend(query.all())
# Customer # Customer (new-style via CustomerShopper)
cls = continuum.version_class(model.Customer)
query = self.Session.query(cls)\
.join(model.CustomerShopper,
model.CustomerShopper.customer_uuid == cls.uuid)\
.filter(model.CustomerShopper.person_uuid == person.uuid)
versions.extend(query.all())
# Customer (old-style via CustomerPerson)
cls = continuum.version_class(model.Customer) cls = continuum.version_class(model.Customer)
query = self.Session.query(cls)\ query = self.Session.query(cls)\
.join(model.CustomerPerson, model.CustomerPerson.customer_uuid == cls.uuid)\ .join(model.CustomerPerson, model.CustomerPerson.customer_uuid == cls.uuid)\
.filter(model.CustomerPerson.person_uuid == person.uuid) .filter(model.CustomerPerson.person_uuid == person.uuid)
versions.extend(query.all()) versions.extend(query.all())
# CustomerPerson
cls = continuum.version_class(model.CustomerPerson)
query = self.Session.query(cls)\
.filter(cls.person_uuid == person.uuid)
versions.extend(query.all())
# nb. this is used in some queries below # nb. this is used in some queries below
FirstShopper = orm.aliased(model.CustomerShopper) FirstShopper = orm.aliased(model.CustomerShopper)