Fix how we obtain local system title for importers

we just can't go around assuming a handler is always in use
This commit is contained in:
Lance Edgar 2020-08-12 15:10:33 -05:00
parent 87f11679b9
commit 8cebc88068

View file

@ -130,6 +130,14 @@ class Importer(object):
self.model_name = self.model_class.__name__
self._setup(**kwargs)
def get_local_system_title(self):
"""
Retrieve the system title for the local/target side.
"""
if hasattr(self, 'handler'):
return self.handler.local_title
return self.local_system_title or "??"
def include_fields(self, *args):
"""
Add the given fields to the supported field list for the importer. May
@ -296,7 +304,7 @@ class Importer(object):
try:
self.progress_loop(import_, data, message="{}ing {} data to {}".format(
self.direction.capitalize(), self.model_name, self.handler.local_title))
self.direction.capitalize(), self.model_name, self.get_local_system_title()))
except ImportLimitReached:
pass
self.flush_create_update_final()
@ -469,14 +477,14 @@ class Importer(object):
self.progress_loop(cache, objects,
message="Reading {} data from {}".format(
self.model_name, self.handler.local_title))
self.model_name, self.get_local_system_title()))
return cached
def cache_local_message(self):
"""
Must return a message to be used for progress when fetching "local" data.
"""
return "Reading {} data from {}".format(self.model_name, self.handler.local_title)
return "Reading {} data from {}".format(self.model_name, self.get_local_system_title())
def get_cache_key(self, obj, normal):
"""