Use custom data model where possible, when importing from CORE API
not sure if this really does much good, but what the heck
This commit is contained in:
parent
1fe48d91f6
commit
6dbf7cf174
|
@ -34,7 +34,6 @@ from sqlalchemy.orm.exc import NoResultFound
|
|||
from corepos.api import CoreWebAPI
|
||||
|
||||
from rattail import importing
|
||||
from rattail.db import model
|
||||
from rattail.gpc import GPC
|
||||
from rattail.util import OrderedDict
|
||||
from rattail.time import localtime, make_utc
|
||||
|
@ -219,6 +218,7 @@ class PersonImporter(FromCOREPOSAPI, corepos_importing.model.PersonImporter):
|
|||
if hasattr(self, 'customers'):
|
||||
return self.customers.get(id)
|
||||
|
||||
model = self.config.get_model()
|
||||
try:
|
||||
return self.session.query(model.Customer)\
|
||||
.filter(model.Customer.id == id)\
|
||||
|
@ -305,6 +305,7 @@ class CustomerPersonImporter(FromCOREPOSAPI, importing.model.CustomerPersonImpor
|
|||
if hasattr(self, 'customers'):
|
||||
return self.customers.get(account_id)
|
||||
|
||||
model = self.config.get_model()
|
||||
try:
|
||||
return self.session.query(model.Customer)\
|
||||
.join(model.CoreCustomer)\
|
||||
|
@ -554,6 +555,7 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
|
|||
|
||||
def setup(self):
|
||||
super(MemberImporter, self).setup()
|
||||
model = self.config.get_model()
|
||||
self.customers = self.cache_model(model.Customer, key='number')
|
||||
|
||||
def get_host_objects(self):
|
||||
|
@ -563,6 +565,7 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
|
|||
if hasattr(self, 'customers'):
|
||||
return self.customers.get(number)
|
||||
|
||||
model = self.config.get_model()
|
||||
try:
|
||||
return self.session.query(model.Customer)\
|
||||
.filter(model.Customer.number == number)\
|
||||
|
|
Loading…
Reference in a new issue