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
					
				
					 3 changed files with 37 additions and 3 deletions
				
			
		
							
								
								
									
										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…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar