From aa87ce57bedfce6003041d61ade51fa2aa5f6f45 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 4 Oct 2023 15:54:52 -0500 Subject: [PATCH] Rename all tables/models for Harvest "cache" make this more explicit, for better naming convention --- .../53c066772ad5_rename_cache_tables.py | 179 ++++++++++++++++++ rattail_harvest/db/model/__init__.py | 8 +- rattail_harvest/db/model/harvest.py | 105 +++++++--- rattail_harvest/importing/harvest.py | 36 ++-- rattail_harvest/importing/model.py | 32 ++-- rattail_harvest/importing/rattail.py | 20 +- rattail_harvest/importing/versions.py | 32 ++-- 7 files changed, 324 insertions(+), 88 deletions(-) create mode 100644 rattail_harvest/db/alembic/versions/53c066772ad5_rename_cache_tables.py diff --git a/rattail_harvest/db/alembic/versions/53c066772ad5_rename_cache_tables.py b/rattail_harvest/db/alembic/versions/53c066772ad5_rename_cache_tables.py new file mode 100644 index 0000000..b185837 --- /dev/null +++ b/rattail_harvest/db/alembic/versions/53c066772ad5_rename_cache_tables.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8; -*- +"""rename cache tables + +Revision ID: 53c066772ad5 +Revises: f2a1650e7fbc +Create Date: 2023-10-04 15:19:03.857323 + +""" + +# revision identifiers, used by Alembic. +revision = '53c066772ad5' +down_revision = 'f2a1650e7fbc' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa +import rattail.db.types + + + +def upgrade(): + + ############################## + # drop all constraints + ############################## + + # harvest_time_entry + op.drop_constraint('harvest_time_entry_fk_user', 'harvest_time_entry', type_='foreignkey') + op.drop_constraint('harvest_time_entry_fk_client', 'harvest_time_entry', type_='foreignkey') + op.drop_constraint('harvest_time_entry_fk_project', 'harvest_time_entry', type_='foreignkey') + op.drop_constraint('harvest_time_entry_fk_task', 'harvest_time_entry', type_='foreignkey') + op.drop_constraint('harvest_time_entry_uq_id', 'harvest_time_entry', type_='unique') + + # harvest_task + op.drop_constraint('harvest_task_uq_id', 'harvest_task', type_='unique') + + # harvest_project + op.drop_constraint('harvest_project_fk_client', 'harvest_project', type_='foreignkey') + op.drop_constraint('harvest_project_uq_id', 'harvest_project', type_='unique') + + # harvest_client + op.drop_constraint('harvest_client_uq_id', 'harvest_client', type_='unique') + + # harvest_user + op.drop_constraint('harvest_user_fk_person', 'harvest_user', type_='foreignkey') + op.drop_constraint('harvest_user_uq_id', 'harvest_user', type_='unique') + + ############################## + # rename all tables + ############################## + + op.rename_table('harvest_user', 'harvest_cache_user') + op.rename_table('harvest_user_version', 'harvest_cache_user_version') + op.rename_table('harvest_client', 'harvest_cache_client') + op.rename_table('harvest_client_version', 'harvest_cache_client_version') + op.rename_table('harvest_project', 'harvest_cache_project') + op.rename_table('harvest_project_version', 'harvest_cache_project_version') + op.rename_table('harvest_task', 'harvest_cache_task') + op.rename_table('harvest_task_version', 'harvest_cache_task_version') + op.rename_table('harvest_time_entry', 'harvest_cache_time_entry') + op.rename_table('harvest_time_entry_version', 'harvest_cache_time_entry_version') + + ############################## + # re-create all constraints + ############################## + + # harvest_cache_user + op.create_foreign_key('harvest_cache_user_fk_person', + 'harvest_cache_user', 'person', + ['person_uuid'], ['uuid']) + op.create_unique_constraint('harvest_cache_user_uq_id', 'harvest_cache_user', ['id']) + + # harvest_cache_client + op.create_unique_constraint('harvest_cache_client_uq_id', 'harvest_cache_client', ['id']) + + # harvest_cache_project + op.create_foreign_key('harvest_cache_project_fk_client', + 'harvest_cache_project', 'harvest_cache_client', + ['client_id'], ['id']) + op.create_unique_constraint('harvest_cache_project_uq_id', 'harvest_cache_project', ['id']) + + # harvest_cache_task + op.create_unique_constraint('harvest_cache_task_uq_id', 'harvest_cache_task', ['id']) + + # harvest_cache_time_entry + op.create_foreign_key('harvest_cache_time_entry_fk_user', + 'harvest_cache_time_entry', 'harvest_cache_user', + ['user_id'], ['id']) + op.create_foreign_key('harvest_cache_time_entry_fk_client', + 'harvest_cache_time_entry', 'harvest_cache_client', + ['client_id'], ['id']) + op.create_foreign_key('harvest_cache_time_entry_fk_project', + 'harvest_cache_time_entry', 'harvest_cache_project', + ['project_id'], ['id']) + op.create_foreign_key('harvest_cache_time_entry_fk_task', + 'harvest_cache_time_entry', 'harvest_cache_task', + ['task_id'], ['id']) + op.create_unique_constraint('harvest_cache_time_entry_uq_id', 'harvest_cache_time_entry', ['id']) + + +def downgrade(): + + ############################## + # drop all constraints + ############################## + + # harvest_cache_time_entry + op.drop_constraint('harvest_cache_time_entry_fk_user', 'harvest_cache_time_entry', type_='foreignkey') + op.drop_constraint('harvest_cache_time_entry_fk_client', 'harvest_cache_time_entry', type_='foreignkey') + op.drop_constraint('harvest_cache_time_entry_fk_project', 'harvest_cache_time_entry', type_='foreignkey') + op.drop_constraint('harvest_cache_time_entry_fk_task', 'harvest_cache_time_entry', type_='foreignkey') + op.drop_constraint('harvest_cache_time_entry_uq_id', 'harvest_cache_time_entry', type_='unique') + + # harvest_cache_task + op.drop_constraint('harvest_cache_task_uq_id', 'harvest_cache_task', type_='unique') + + # harvest_cache_project + op.drop_constraint('harvest_cache_project_fk_client', 'harvest_cache_project', type_='foreignkey') + op.drop_constraint('harvest_cache_project_uq_id', 'harvest_cache_project', type_='unique') + + # harvest_cache_client + op.drop_constraint('harvest_cache_client_uq_id', 'harvest_cache_client', type_='unique') + + # harvest_cache_user + op.drop_constraint('harvest_cache_user_fk_person', 'harvest_cache_user', type_='foreignkey') + op.drop_constraint('harvest_cache_user_uq_id', 'harvest_cache_user', type_='unique') + + ############################## + # rename all tables + ############################## + + op.rename_table('harvest_cache_user', 'harvest_user') + op.rename_table('harvest_cache_user_version', 'harvest_user_version') + op.rename_table('harvest_cache_client', 'harvest_client') + op.rename_table('harvest_cache_client_version', 'harvest_client_version') + op.rename_table('harvest_cache_project', 'harvest_project') + op.rename_table('harvest_cache_project_version', 'harvest_project_version') + op.rename_table('harvest_cache_task', 'harvest_task') + op.rename_table('harvest_cache_task_version', 'harvest_task_version') + op.rename_table('harvest_cache_time_entry', 'harvest_time_entry') + op.rename_table('harvest_cache_time_entry_version', 'harvest_time_entry_version') + + ############################## + # re-create all constraints + ############################## + + # harvest_user + op.create_foreign_key('harvest_user_fk_person', + 'harvest_user', 'person', + ['person_uuid'], ['uuid']) + op.create_unique_constraint('harvest_user_uq_id', 'harvest_user', ['id']) + + # harvest_client + op.create_unique_constraint('harvest_client_uq_id', 'harvest_client', ['id']) + + # harvest_project + op.create_foreign_key('harvest_project_fk_client', + 'harvest_project', 'harvest_client', + ['client_id'], ['id']) + op.create_unique_constraint('harvest_project_uq_id', 'harvest_project', ['id']) + + # harvest_cache_task + op.create_unique_constraint('harvest_task_uq_id', 'harvest_task', ['id']) + + # harvest_time_entry + op.create_foreign_key('harvest_time_entry_fk_user', + 'harvest_time_entry', 'harvest_user', + ['user_id'], ['id']) + op.create_foreign_key('harvest_time_entry_fk_client', + 'harvest_time_entry', 'harvest_client', + ['client_id'], ['id']) + op.create_foreign_key('harvest_time_entry_fk_project', + 'harvest_time_entry', 'harvest_project', + ['project_id'], ['id']) + op.create_foreign_key('harvest_time_entry_fk_task', + 'harvest_time_entry', 'harvest_task', + ['task_id'], ['id']) + op.create_unique_constraint('harvest_time_entry_uq_id', 'harvest_time_entry', ['id']) diff --git a/rattail_harvest/db/model/__init__.py b/rattail_harvest/db/model/__init__.py index e55b2a1..0d58bc1 100644 --- a/rattail_harvest/db/model/__init__.py +++ b/rattail_harvest/db/model/__init__.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -24,5 +24,9 @@ Harvest integration data models """ -from .harvest import (HarvestUser, HarvestClient, HarvestProject, +from .harvest import (HarvestCacheUser, HarvestCacheClient, + HarvestCacheProject, HarvestCacheTask, + HarvestCacheTimeEntry, + # TODO: deprecate / remove these + HarvestUser, HarvestClient, HarvestProject, HarvestTask, HarvestTimeEntry) diff --git a/rattail_harvest/db/model/harvest.py b/rattail_harvest/db/model/harvest.py index fd3a8ee..f3fec9b 100644 --- a/rattail_harvest/db/model/harvest.py +++ b/rattail_harvest/db/model/harvest.py @@ -24,6 +24,8 @@ Harvest "cache" data models """ +import warnings + import sqlalchemy as sa from sqlalchemy import orm @@ -31,16 +33,17 @@ from rattail.db import model from rattail.db.util import normalize_full_name -class HarvestUser(model.Base): +class HarvestCacheUser(model.Base): """ Represents a user record in Harvest. https://help.getharvest.com/api-v2/users-api/users/users/#the-user-object """ - __tablename__ = 'harvest_user' + __tablename__ = 'harvest_cache_user' __table_args__ = ( - sa.ForeignKeyConstraint(['person_uuid'], ['person.uuid'], name='harvest_user_fk_person'), - sa.UniqueConstraint('id', name='harvest_user_uq_id'), + sa.ForeignKeyConstraint(['person_uuid'], ['person.uuid'], + name='harvest_cache_user_fk_person'), + sa.UniqueConstraint('id', name='harvest_cache_user_uq_id'), ) __versioned__ = {} @@ -108,15 +111,24 @@ class HarvestUser(model.Base): return normalize_full_name(self.first_name, self.last_name) -class HarvestClient(model.Base): +class HarvestUser(HarvestCacheUser): + """ DEPRECATED """ + + def __init__(self, *args, **kwargs): + warnings.warn("HarvestUser class is deprecated; " + "please use HarvestCacheUser instead", + DeprecationWarning, stacklevel=2) + + +class HarvestCacheClient(model.Base): """ Represents a client record in Harvest. https://help.getharvest.com/api-v2/clients-api/clients/clients/#the-client-object """ - __tablename__ = 'harvest_client' + __tablename__ = 'harvest_cache_client' __table_args__ = ( - sa.UniqueConstraint('id', name='harvest_client_uq_id'), + sa.UniqueConstraint('id', name='harvest_cache_client_uq_id'), ) __versioned__ = {} @@ -140,16 +152,26 @@ class HarvestClient(model.Base): return self.name or '' -class HarvestProject(model.Base): +class HarvestClient(HarvestCacheClient): + """ DEPRECATED """ + + def __init__(self, *args, **kwargs): + warnings.warn("HarvestClient class is deprecated; " + "please use HarvestCacheClient instead", + DeprecationWarning, stacklevel=2) + + +class HarvestCacheProject(model.Base): """ Represents a project record in Harvest. https://help.getharvest.com/api-v2/projects-api/projects/projects/#the-project-object """ - __tablename__ = 'harvest_project' + __tablename__ = 'harvest_cache_project' __table_args__ = ( - sa.UniqueConstraint('id', name='harvest_project_uq_id'), - sa.ForeignKeyConstraint(['client_id'], ['harvest_client.id'], name='harvest_project_fk_client'), + sa.UniqueConstraint('id', name='harvest_cache_project_uq_id'), + sa.ForeignKeyConstraint(['client_id'], ['harvest_cache_client.id'], + name='harvest_cache_project_fk_client'), ) __versioned__ = {'exclude': ['over_budget_notification_date']} @@ -158,7 +180,7 @@ class HarvestProject(model.Base): id = sa.Column(sa.BigInteger(), nullable=False) client_id = sa.Column(sa.BigInteger(), nullable=True) # TODO: should not allow null? - client = orm.relationship(HarvestClient, backref=orm.backref('projects')) + client = orm.relationship(HarvestCacheClient, backref=orm.backref('projects')) name = sa.Column(sa.String(length=255), nullable=True) @@ -212,15 +234,24 @@ class HarvestProject(model.Base): return self.name or '' -class HarvestTask(model.Base): +class HarvestProject(HarvestCacheProject): + """ DEPRECATED """ + + def __init__(self, *args, **kwargs): + warnings.warn("HarvestProject class is deprecated; " + "please use HarvestCacheProject instead", + DeprecationWarning, stacklevel=2) + + +class HarvestCacheTask(model.Base): """ Represents a task record in Harvest. https://help.getharvest.com/api-v2/tasks-api/tasks/tasks/#the-task-object """ - __tablename__ = 'harvest_task' + __tablename__ = 'harvest_cache_task' __table_args__ = ( - sa.UniqueConstraint('id', name='harvest_task_uq_id'), + sa.UniqueConstraint('id', name='harvest_cache_task_uq_id'), ) __versioned__ = {} @@ -246,19 +277,32 @@ class HarvestTask(model.Base): return self.name or '' -class HarvestTimeEntry(model.Base): +class HarvestTask(HarvestCacheTask): + """ DEPRECATED """ + + def __init__(self, *args, **kwargs): + warnings.warn("HarvestTask class is deprecated; " + "please use HarvestCacheTask instead", + DeprecationWarning, stacklevel=2) + + +class HarvestCacheTimeEntry(model.Base): """ Represents a time entry record in Harvest. https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/#the-time-entry-object """ - __tablename__ = 'harvest_time_entry' + __tablename__ = 'harvest_cache_time_entry' __table_args__ = ( - sa.UniqueConstraint('id', name='harvest_time_entry_uq_id'), - sa.ForeignKeyConstraint(['user_id'], ['harvest_user.id'], name='harvest_time_entry_fk_user'), - sa.ForeignKeyConstraint(['client_id'], ['harvest_client.id'], name='harvest_time_entry_fk_client'), - sa.ForeignKeyConstraint(['project_id'], ['harvest_project.id'], name='harvest_time_entry_fk_project'), - sa.ForeignKeyConstraint(['task_id'], ['harvest_task.id'], name='harvest_time_entry_fk_task'), + sa.UniqueConstraint('id', name='harvest_cache_time_entry_uq_id'), + sa.ForeignKeyConstraint(['user_id'], ['harvest_cache_user.id'], + name='harvest_cache_time_entry_fk_user'), + sa.ForeignKeyConstraint(['client_id'], ['harvest_cache_client.id'], + name='harvest_cache_time_entry_fk_client'), + sa.ForeignKeyConstraint(['project_id'], ['harvest_cache_project.id'], + name='harvest_cache_time_entry_fk_project'), + sa.ForeignKeyConstraint(['task_id'], ['harvest_cache_task.id'], + name='harvest_cache_time_entry_fk_task'), ) __versioned__ = {} model_title_plural = "Harvest Time Entries" @@ -270,16 +314,16 @@ class HarvestTimeEntry(model.Base): spent_date = sa.Column(sa.Date(), nullable=True) user_id = sa.Column(sa.BigInteger(), nullable=True) - user = orm.relationship(HarvestUser, backref=orm.backref('time_entries')) + user = orm.relationship(HarvestCacheUser, backref=orm.backref('time_entries')) client_id = sa.Column(sa.BigInteger(), nullable=True) - client = orm.relationship(HarvestClient, backref=orm.backref('time_entries')) + client = orm.relationship(HarvestCacheClient, backref=orm.backref('time_entries')) project_id = sa.Column(sa.BigInteger(), nullable=True) - project = orm.relationship(HarvestProject, backref=orm.backref('time_entries')) + project = orm.relationship(HarvestCacheProject, backref=orm.backref('time_entries')) task_id = sa.Column(sa.BigInteger(), nullable=True) - task = orm.relationship(HarvestTask, backref=orm.backref('time_entries')) + task = orm.relationship(HarvestCacheTask, backref=orm.backref('time_entries')) invoice_id = sa.Column(sa.BigInteger(), nullable=True) @@ -317,3 +361,12 @@ class HarvestTimeEntry(model.Base): def __str__(self): return str(self.spent_date or '') + + +class HarvestTimeEntry(HarvestCacheTimeEntry): + """ DEPRECATED """ + + def __init__(self, *args, **kwargs): + warnings.warn("HarvestTimeEntry class is deprecated; " + "please use HarvestCacheTimeEntry instead", + DeprecationWarning, stacklevel=2) diff --git a/rattail_harvest/importing/harvest.py b/rattail_harvest/importing/harvest.py index 1da4cd2..4f22ef1 100644 --- a/rattail_harvest/importing/harvest.py +++ b/rattail_harvest/importing/harvest.py @@ -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 diff --git a/rattail_harvest/importing/model.py b/rattail_harvest/importing/model.py index 715f5a8..5e35839 100644 --- a/rattail_harvest/importing/model.py +++ b/rattail_harvest/importing/model.py @@ -37,20 +37,20 @@ log = logging.getLogger(__name__) # harvest cache models ############################## -class HarvestUserImporter(ToRattail): - model_class = model.HarvestUser +class HarvestCacheUserImporter(ToRattail): + model_class = model.HarvestCacheUser -class HarvestClientImporter(ToRattail): - model_class = model.HarvestClient +class HarvestCacheClientImporter(ToRattail): + model_class = model.HarvestCacheClient -class HarvestProjectImporter(ToRattail): - model_class = model.HarvestProject +class HarvestCacheProjectImporter(ToRattail): + model_class = model.HarvestCacheProject -class HarvestTaskImporter(ToRattail): - model_class = model.HarvestTask +class HarvestCacheTaskImporter(ToRattail): + model_class = model.HarvestCacheTask -class HarvestTimeEntryImporter(ToRattail): - model_class = model.HarvestTimeEntry +class HarvestCacheTimeEntryImporter(ToRattail): + model_class = model.HarvestCacheTimeEntry # flags to auto-create records for "unknown" references auto_create_unknown_project = True @@ -59,12 +59,12 @@ class HarvestTimeEntryImporter(ToRattail): warn_for_unknown_project = True def setup(self): - super(HarvestTimeEntryImporter, self).setup() + super().setup() model = self.model if 'project_id' in self.fields: self.harvest_projects_by_id = self.app.cache_model( - self.session, model.HarvestProject, key='id') + self.session, model.HarvestCacheProject, key='id') def cache_query(self): query = super().cache_query() @@ -81,12 +81,12 @@ class HarvestTimeEntryImporter(ToRattail): return self.harvest_projects_by_id.get(project_id) model = self.model - return self.session.query(model.HarvestProject)\ - .filter(model.HarvestProject.id == project_id)\ + return self.session.query(model.HarvestCacheProject)\ + .filter(model.HarvestCacheProject.id == project_id)\ .first() def update_object(self, entry, data, local_data=None): - entry = super(HarvestTimeEntryImporter, self).update_object(entry, data, local_data) + entry = super().update_object(entry, data, local_data) model = self.model if 'project_id' in self.fields: @@ -97,7 +97,7 @@ class HarvestTimeEntryImporter(ToRattail): logger("unknown project id %s for time entry id %s: %s", project_id, entry.id, entry) if self.auto_create_unknown_project: - project = model.HarvestProject() + project = model.HarvestCacheProject() project.id = project_id project.name = "(unknown)" self.session.add(project) diff --git a/rattail_harvest/importing/rattail.py b/rattail_harvest/importing/rattail.py index d61f3d8..ab67489 100644 --- a/rattail_harvest/importing/rattail.py +++ b/rattail_harvest/importing/rattail.py @@ -34,11 +34,11 @@ class FromRattailToRattailHarvestMixin(object): """ def add_harvest_importers(self, importers): - 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 @@ -46,19 +46,19 @@ class FromRattailToRattailHarvestMixin(object): # harvest cache models ############################## -class HarvestUserImporter(base.FromRattail, rattail_harvest_importing.model.HarvestUserImporter): +class HarvestCacheUserImporter(base.FromRattail, rattail_harvest_importing.model.HarvestCacheUserImporter): pass -class HarvestClientImporter(base.FromRattail, rattail_harvest_importing.model.HarvestClientImporter): +class HarvestCacheClientImporter(base.FromRattail, rattail_harvest_importing.model.HarvestCacheClientImporter): pass -class HarvestProjectImporter(base.FromRattail, rattail_harvest_importing.model.HarvestProjectImporter): +class HarvestCacheProjectImporter(base.FromRattail, rattail_harvest_importing.model.HarvestCacheProjectImporter): pass -class HarvestTaskImporter(base.FromRattail, rattail_harvest_importing.model.HarvestTaskImporter): +class HarvestCacheTaskImporter(base.FromRattail, rattail_harvest_importing.model.HarvestCacheTaskImporter): pass -class HarvestTimeEntryImporter(base.FromRattail, rattail_harvest_importing.model.HarvestTimeEntryImporter): +class HarvestCacheTimeEntryImporter(base.FromRattail, rattail_harvest_importing.model.HarvestCacheTimeEntryImporter): def query(self): query = super().query() diff --git a/rattail_harvest/importing/versions.py b/rattail_harvest/importing/versions.py index 3dd5571..e82d861 100644 --- a/rattail_harvest/importing/versions.py +++ b/rattail_harvest/importing/versions.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -30,44 +30,44 @@ from rattail.importing import versions as base class HarvestVersionMixin(object): def add_harvest_importers(self, importers): - 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 -class HarvestUserImporter(base.VersionImporter): +class HarvestCacheUserImporter(base.VersionImporter): @property def host_model_class(self): - return self.model.HarvestUser + return self.model.HarvestCacheUser -class HarvestClientImporter(base.VersionImporter): +class HarvestCacheClientImporter(base.VersionImporter): @property def host_model_class(self): - return self.model.HarvestClient + return self.model.HarvestCacheClient -class HarvestProjectImporter(base.VersionImporter): +class HarvestCacheProjectImporter(base.VersionImporter): @property def host_model_class(self): - return self.model.HarvestProject + return self.model.HarvestCacheProject -class HarvestTaskImporter(base.VersionImporter): +class HarvestCacheTaskImporter(base.VersionImporter): @property def host_model_class(self): - return self.model.HarvestTask + return self.model.HarvestCacheTask -class HarvestTimeEntryImporter(base.VersionImporter): +class HarvestCacheTimeEntryImporter(base.VersionImporter): @property def host_model_class(self): - return self.model.HarvestTimeEntry + return self.model.HarvestCacheTimeEntry