Remove DB-related things from the Rattail -> CORE datasync consumer
since that should only use API, going forward
This commit is contained in:
parent
4180382250
commit
f9071ac6e9
|
@ -138,17 +138,6 @@ class FromRattailToCore(NewDataSyncImportConsumer):
|
||||||
"""
|
"""
|
||||||
handler_spec = 'rattail_corepos.corepos.importing.rattail:FromRattailToCore'
|
handler_spec = 'rattail_corepos.corepos.importing.rattail:FromRattailToCore'
|
||||||
|
|
||||||
def begin_transaction(self):
|
|
||||||
self.corepos_session = CoreSession()
|
|
||||||
|
|
||||||
def rollback_transaction(self):
|
|
||||||
self.corepos_session.rollback()
|
|
||||||
self.corepos_session.close()
|
|
||||||
|
|
||||||
def commit_transaction(self):
|
|
||||||
self.corepos_session.commit()
|
|
||||||
self.corepos_session.close()
|
|
||||||
|
|
||||||
def process_changes(self, session, changes):
|
def process_changes(self, session, changes):
|
||||||
"""
|
"""
|
||||||
Process all the given changes, coming from Rattail.
|
Process all the given changes, coming from Rattail.
|
||||||
|
@ -157,27 +146,27 @@ class FromRattailToCore(NewDataSyncImportConsumer):
|
||||||
if self.runas_username:
|
if self.runas_username:
|
||||||
session.set_continuum_user(self.runas_username)
|
session.set_continuum_user(self.runas_username)
|
||||||
|
|
||||||
# update all importers with current Rattail/CORE sessions
|
# update all importers with current session
|
||||||
for importer in self.importers.values():
|
for importer in self.importers.values():
|
||||||
importer.host_session = session
|
importer.host_session = session
|
||||||
importer.session = self.corepos_session
|
|
||||||
# also establish the API client for each!
|
# also establish the API client for each!
|
||||||
importer.establish_api()
|
importer.establish_api()
|
||||||
|
|
||||||
# next pass syncs all Vendor changes
|
# sync all Vendor changes
|
||||||
types = [
|
types = [
|
||||||
'Vendor',
|
'Vendor',
|
||||||
'VendorPhoneNumber',
|
'VendorPhoneNumber',
|
||||||
'VendorEmailAddress',
|
'VendorEmailAddress',
|
||||||
]
|
]
|
||||||
for change in [c for c in changes if c.payload_type in types]:
|
for change in [c for c in changes if c.payload_type in types]:
|
||||||
|
if change.payload_type == 'Vendor' and change.deletion:
|
||||||
|
# just do default logic for this one
|
||||||
|
self.invoke_importer(session, change)
|
||||||
|
else: # we consider this a "vendor add/update"
|
||||||
vendor = self.get_host_vendor(session, change)
|
vendor = self.get_host_vendor(session, change)
|
||||||
if vendor:
|
if vendor:
|
||||||
# TODO: what about "deletions" - not sure what happens yet
|
|
||||||
self.process_change(session, self.importers['Vendor'],
|
self.process_change(session, self.importers['Vendor'],
|
||||||
host_object=vendor)
|
host_object=vendor)
|
||||||
# self.process_change(session, self.importers['VendorContact'],
|
|
||||||
# host_object=vendor)
|
|
||||||
|
|
||||||
def get_host_vendor(self, session, change):
|
def get_host_vendor(self, session, change):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue