Changeset - 874cbc4462bd
[Not reviewed]
1 3 0
Lance Edgar - 6 years ago 2019-02-18 21:27:57
ledgar@techsupport.coop
Clean up Rattail <-> Rattail import/export handlers a bit
4 files changed with 19 insertions and 317 deletions:
0 comments (0 inline, 0 general)
rattail/importing/rattail.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2017 Lance Edgar
 
#  Copyright © 2010-2019 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
#  Rattail is free software: you can redistribute it and/or modify it under the
 
#  terms of the GNU General Public License as published by the Free Software
 
#  Foundation, either version 3 of the License, or (at your option) any later
 
@@ -124,37 +124,40 @@ class FromRattailToRattailBase(object):
 
            keys.remove('ProductImage')
 
        return keys
 

	
 

	
 
class FromRattailToRattailImport(FromRattailToRattailBase, FromRattailHandler, ToRattailHandler):
 
    """
 
    Handler for Rattail -> Rattail data import.
 
    Handler for Rattail (other) -> Rattail (local) data import.
 
    """
 
    local_title = "Rattail (local)"
 
    dbkey = 'host'
 

	
 
    @property
 
    def host_title(self):
 
        return "Rattail ({})".format(self.dbkey)
 
        return "{} ({})".format(self.config.app_title(default="Rattail"), self.dbkey)
 

	
 
    @property
 
    def local_title(self):
 
        return self.config.node_title()
 

	
 
    def make_host_session(self):
 
        return Session(bind=self.config.rattail_engines[self.dbkey])
 

	
 
# TODO: deprecate/remove this?
 
FromRattailToRattail = FromRattailToRattailImport
 

	
 

	
 
class FromRattailToRattailExport(FromRattailToRattailBase, FromRattailHandler, ToRattailHandler):
 
    """
 
    Handler for Rattail -> Rattail data import.
 
    Handler for Rattail (local) -> Rattail (other) data export.
 
    """
 
    host_title = "Rattail (default)"
 

	
 
    @property
 
    def host_title(self):
 
        return self.config.node_title()
 

	
 
    @property
 
    def local_title(self):
 
        return "Rattail ({})".format(self.dbkey)
 
        return "{} ({})".format(self.config.app_title(default="Rattail"), self.dbkey)
 

	
 
    def make_session(self):
 
        return Session(bind=self.config.rattail_engines[self.dbkey])
 

	
 

	
 
class FromRattail(FromSQLAlchemy):
rattail/importing/rattail_bulk.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
# -*- coding: utf-8; -*-
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2017 Lance Edgar
 
#  Copyright © 2010-2019 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
#  Rattail is free software: you can redistribute it and/or modify it under the
 
#  terms of the GNU General Public License as published by the Free Software
 
#  Foundation, either version 3 of the License, or (at your option) any later
 
@@ -25,16 +25,16 @@ Rattail -> Rattail bulk data import
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from rattail import importing
 
from rattail.util import OrderedDict
 
from rattail.importing.rattail import FromRattailToRattail, FromRattail
 
from rattail.importing.rattail import FromRattailToRattailImport, FromRattail
 

	
 

	
 
class BulkFromRattailToRattail(FromRattailToRattail, importing.BulkImportHandler):
 
class BulkFromRattailToRattail(FromRattailToRattailImport, importing.BulkImportHandler):
 
    """
 
    Handler for Rattail -> Rattail bulk data import.
 
    """
 

	
 
    def get_importers(self):
 
        importers = OrderedDict()
rattail/tests/commands/test_importing.py.bak
Show inline comments
 
deleted file
rattail/tests/importing/test_rattail.py
Show inline comments
 
@@ -53,13 +53,13 @@ class TestFromRattailHandler(RattailTestCase, ImporterTester):
 
        session = handler.make_host_session()
 
        self.assertIsInstance(session, SessionBase)
 
        self.assertIs(session.bind, self.config.rattail_engine)
 

	
 

	
 
class TestFromRattailToRattail(DualRattailTestCase, ImporterTester):
 
    handler_class = rattail_importing.FromRattailToRattail
 
    handler_class = rattail_importing.FromRattailToRattailImport
 

	
 
    def test_host_title(self):
 
        handler = self.make_handler()
 
        self.assertEqual(handler.host_title, "Rattail (host)")
 

	
 
    # TODO
0 comments (0 inline, 0 general)