Rename all tables/models for Harvest "cache"
make this more explicit, for better naming convention
This commit is contained in:
parent
509405cb34
commit
aa87ce57be
7 changed files with 324 additions and 88 deletions
|
@ -49,11 +49,11 @@ class FromHarvestToRattail(importing.ToRattailHandler):
|
|||
|
||||
def get_importers(self):
|
||||
importers = OrderedDict()
|
||||
importers['HarvestUser'] = HarvestUserImporter
|
||||
importers['HarvestClient'] = HarvestClientImporter
|
||||
importers['HarvestProject'] = HarvestProjectImporter
|
||||
importers['HarvestTask'] = HarvestTaskImporter
|
||||
importers['HarvestTimeEntry'] = HarvestTimeEntryImporter
|
||||
importers['HarvestCacheUser'] = HarvestCacheUserImporter
|
||||
importers['HarvestCacheClient'] = HarvestCacheClientImporter
|
||||
importers['HarvestCacheProject'] = HarvestCacheProjectImporter
|
||||
importers['HarvestCacheTask'] = HarvestCacheTaskImporter
|
||||
importers['HarvestCacheTimeEntry'] = HarvestCacheTimeEntryImporter
|
||||
return importers
|
||||
|
||||
|
||||
|
@ -90,14 +90,14 @@ class FromHarvest(importing.Importer):
|
|||
return data
|
||||
|
||||
|
||||
class HarvestUserImporter(FromHarvest, rattail_harvest_importing.model.HarvestUserImporter):
|
||||
class HarvestCacheUserImporter(FromHarvest, rattail_harvest_importing.model.HarvestCacheUserImporter):
|
||||
"""
|
||||
Import user data from Harvest
|
||||
"""
|
||||
|
||||
@property
|
||||
def supported_fields(self):
|
||||
fields = list(super(HarvestUserImporter, self).supported_fields)
|
||||
fields = list(super().supported_fields)
|
||||
|
||||
# this is for local tracking only; is not in harvest
|
||||
fields.remove('person_uuid')
|
||||
|
@ -111,7 +111,7 @@ class HarvestUserImporter(FromHarvest, rattail_harvest_importing.model.HarvestUs
|
|||
return self.webapi.get_users()['users']
|
||||
|
||||
def normalize_host_object(self, user):
|
||||
data = super(HarvestUserImporter, self).normalize_host_object(user)
|
||||
data = super().normalize_host_object(user)
|
||||
if data:
|
||||
|
||||
# TODO: for some reason the API used to include the these
|
||||
|
@ -131,7 +131,7 @@ class HarvestUserImporter(FromHarvest, rattail_harvest_importing.model.HarvestUs
|
|||
return data
|
||||
|
||||
|
||||
class HarvestClientImporter(FromHarvest, rattail_harvest_importing.model.HarvestClientImporter):
|
||||
class HarvestCacheClientImporter(FromHarvest, rattail_harvest_importing.model.HarvestCacheClientImporter):
|
||||
"""
|
||||
Import client data from Harvest
|
||||
"""
|
||||
|
@ -140,14 +140,14 @@ class HarvestClientImporter(FromHarvest, rattail_harvest_importing.model.Harvest
|
|||
return self.webapi.get_clients()['clients']
|
||||
|
||||
|
||||
class HarvestProjectImporter(FromHarvest, rattail_harvest_importing.model.HarvestProjectImporter):
|
||||
class HarvestCacheProjectImporter(FromHarvest, rattail_harvest_importing.model.HarvestCacheProjectImporter):
|
||||
"""
|
||||
Import project data from Harvest
|
||||
"""
|
||||
|
||||
@property
|
||||
def supported_fields(self):
|
||||
fields = list(super(HarvestProjectImporter, self).supported_fields)
|
||||
fields = list(super().supported_fields)
|
||||
|
||||
# this is for local tracking only; is not in harvest
|
||||
fields.remove('deleted')
|
||||
|
@ -156,16 +156,16 @@ class HarvestProjectImporter(FromHarvest, rattail_harvest_importing.model.Harves
|
|||
|
||||
def cache_query(self):
|
||||
model = self.model
|
||||
return self.session.query(model.HarvestProject)\
|
||||
return self.session.query(model.HarvestCacheProject)\
|
||||
.filter(sa.or_(
|
||||
model.HarvestProject.deleted == False,
|
||||
model.HarvestProject.deleted == None))
|
||||
model.HarvestCacheProject.deleted == False,
|
||||
model.HarvestCacheProject.deleted == None))
|
||||
|
||||
def get_host_objects(self):
|
||||
return self.webapi.get_projects()
|
||||
|
||||
def normalize_host_object(self, project):
|
||||
data = super(HarvestProjectImporter, self).normalize_host_object(project)
|
||||
data = super().normalize_host_object(project)
|
||||
if not data:
|
||||
return
|
||||
|
||||
|
@ -211,7 +211,7 @@ class HarvestProjectImporter(FromHarvest, rattail_harvest_importing.model.Harves
|
|||
return True
|
||||
|
||||
|
||||
class HarvestTaskImporter(FromHarvest, rattail_harvest_importing.model.HarvestTaskImporter):
|
||||
class HarvestCacheTaskImporter(FromHarvest, rattail_harvest_importing.model.HarvestCacheTaskImporter):
|
||||
"""
|
||||
Import task data from Harvest
|
||||
"""
|
||||
|
@ -220,7 +220,7 @@ class HarvestTaskImporter(FromHarvest, rattail_harvest_importing.model.HarvestTa
|
|||
return self.webapi.get_tasks()['tasks']
|
||||
|
||||
|
||||
class HarvestTimeEntryImporter(FromHarvest, rattail_harvest_importing.model.HarvestTimeEntryImporter):
|
||||
class HarvestCacheTimeEntryImporter(FromHarvest, rattail_harvest_importing.model.HarvestCacheTimeEntryImporter):
|
||||
"""
|
||||
Import time entry data from Harvest
|
||||
"""
|
||||
|
@ -239,7 +239,7 @@ class HarvestTimeEntryImporter(FromHarvest, rattail_harvest_importing.model.Harv
|
|||
return self.webapi.get_time_entry(entry_id)
|
||||
|
||||
def normalize_host_object(self, entry):
|
||||
data = super(HarvestTimeEntryImporter, self).normalize_host_object(entry)
|
||||
data = super().normalize_host_object(entry)
|
||||
if not data:
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue