Override the CORE-API -> Rattail Demo importer for Store data
this lets the demo have random extra Store records and the importer will just ignore them
This commit is contained in:
parent
8cb42712fd
commit
4288e1ce64
|
@ -26,3 +26,4 @@ class DemoConfigExtension(ConfigExtension):
|
|||
|
||||
# default import handlers
|
||||
config.setdefault('rattail.importing', 'versions.handler', 'rattail_demo.importing.versions:FromRattailDemoToRattailDemoVersions')
|
||||
config.setdefault('rattail.importing', 'corepos_api.handler', 'rattail_demo.importing.corepos_api:FromCOREPOSToRattail')
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
Email definitions
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
|
||||
# bring in some common config from rattail
|
||||
from rattail.emails import (upgrade_failure,
|
||||
|
@ -19,3 +17,7 @@ from rattail_tempmon.emails import (tempmon_critical_high_temp,
|
|||
tempmon_critical_low_temp,
|
||||
tempmon_error,
|
||||
tempmon_client_offline)
|
||||
|
||||
# common config from rattail-corepos
|
||||
from rattail_corepos.emails import (rattail_import_corepos_api_updates,
|
||||
rattail_import_corepos_db_updates)
|
||||
|
|
31
rattail_demo/importing/corepos_api.py
Normal file
31
rattail_demo/importing/corepos_api.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
CORE-POS API -> Rattail Demo importing
|
||||
"""
|
||||
|
||||
from rattail_corepos.importing.corepos import api as base
|
||||
|
||||
|
||||
class FromCOREPOSToRattail(base.FromCOREPOSToRattail):
|
||||
"""
|
||||
Override some parts of CORE-POS API -> Rattail importing.
|
||||
"""
|
||||
|
||||
def get_importers(self):
|
||||
importers = super(FromCOREPOSToRattail, self).get_importers()
|
||||
importers['Store'] = StoreImporter
|
||||
return importers
|
||||
|
||||
|
||||
class StoreImporter(base.StoreImporter):
|
||||
"""
|
||||
Tweak how we import Store data from CORE-POS API.
|
||||
"""
|
||||
|
||||
def cache_query(self):
|
||||
model = self.model
|
||||
# we ignore any Store records which are not associated with CORE, so
|
||||
# the importer will never be tempted to delete them etc.
|
||||
return self.session.query(model.Store)\
|
||||
.join(model.CoreStore)\
|
||||
.filter(model.CoreStore.corepos_id != None)
|
Loading…
Reference in a new issue