Refactor per rename of Harvest cache models

This commit is contained in:
Lance Edgar 2023-10-04 15:56:02 -05:00
parent f388f2d6cf
commit eb904aea3b
6 changed files with 47 additions and 47 deletions

View file

@ -24,7 +24,7 @@
Harvest Client views Harvest Client views
""" """
from rattail_harvest.db.model import HarvestClient from rattail_harvest.db.model import HarvestCacheClient
from rattail_harvest.harvest.config import get_harvest_url from rattail_harvest.harvest.config import get_harvest_url
from webhelpers2.html import HTML, tags from webhelpers2.html import HTML, tags
@ -32,11 +32,11 @@ from webhelpers2.html import HTML, tags
from .master import HarvestMasterView from .master import HarvestMasterView
class HarvestClientView(HarvestMasterView): class HarvestCacheClientView(HarvestMasterView):
""" """
Master view for Harvest Clients Master view for Harvest Clients
""" """
model_class = HarvestClient model_class = HarvestCacheClient
url_prefix = '/harvest/clients' url_prefix = '/harvest/clients'
route_prefix = 'harvest.clients' route_prefix = 'harvest.clients'
@ -47,7 +47,7 @@ class HarvestClientView(HarvestMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(HarvestClientView, self).configure_grid(g) super().configure_grid(g)
g.filters['name'].default_active = True g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains' g.filters['name'].default_verb = 'contains'
@ -65,7 +65,7 @@ class HarvestClientView(HarvestMasterView):
return 'warning' return 'warning'
def configure_form(self, f): def configure_form(self, f):
super(HarvestClientView, self).configure_form(f) super().configure_form(f)
# projects # projects
f.set_renderer('projects', self.render_projects) f.set_renderer('projects', self.render_projects)
@ -86,7 +86,7 @@ class HarvestClientView(HarvestMasterView):
return HTML.tag('ul', c=items) return HTML.tag('ul', c=items)
def get_xref_buttons(self, client): def get_xref_buttons(self, client):
buttons = super(HarvestClientView, self).get_xref_buttons(client) buttons = super().get_xref_buttons(client)
model = self.model model = self.model
# harvest proper # harvest proper
@ -102,8 +102,8 @@ class HarvestClientView(HarvestMasterView):
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()
HarvestClientView = kwargs.get('HarvestClientView', base['HarvestClientView']) HarvestCacheClientView = kwargs.get('HarvestCacheClientView', base['HarvestCacheClientView'])
HarvestClientView.defaults(config) HarvestCacheClientView.defaults(config)
def includeme(config): def includeme(config):

View file

@ -24,7 +24,7 @@
Harvest master view Harvest master view
""" """
from rattail_harvest.db.model import HarvestTimeEntry from rattail_harvest.db.model import HarvestCacheTimeEntry
from webhelpers2.html import tags from webhelpers2.html import tags
@ -38,7 +38,7 @@ class HarvestMasterView(MasterView):
creatable = False creatable = False
touchable = True touchable = True
has_versions = True has_versions = True
model_row_class = HarvestTimeEntry model_row_class = HarvestCacheTimeEntry
labels = { labels = {
'id': "ID", 'id': "ID",

View file

@ -24,17 +24,17 @@
Harvest Project views Harvest Project views
""" """
from rattail_harvest.db.model import HarvestProject from rattail_harvest.db.model import HarvestCacheProject
from rattail_harvest.harvest.config import get_harvest_url from rattail_harvest.harvest.config import get_harvest_url
from .master import HarvestMasterView from .master import HarvestMasterView
class HarvestProjectView(HarvestMasterView): class HarvestCacheProjectView(HarvestMasterView):
""" """
Master view for Harvest Projects Master view for Harvest Projects
""" """
model_class = HarvestProject model_class = HarvestCacheProject
url_prefix = '/harvest/projects' url_prefix = '/harvest/projects'
route_prefix = 'harvest.projects' route_prefix = 'harvest.projects'
@ -62,12 +62,12 @@ class HarvestProjectView(HarvestMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(HarvestProjectView, self).configure_grid(g) super().configure_grid(g)
model = self.model model = self.model
g.set_joiner('client', lambda q: q.outerjoin(model.HarvestClient)) g.set_joiner('client', lambda q: q.outerjoin(model.HarvestCacheClient))
g.set_sorter('client', model.HarvestClient.name) g.set_sorter('client', model.HarvestCacheClient.name)
g.set_filter('client', model.HarvestClient.name, label="Client Name") g.set_filter('client', model.HarvestCacheClient.name, label="Client Name")
g.filters['client'].default_active = True g.filters['client'].default_active = True
g.filters['client'].default_verb = 'contains' g.filters['client'].default_verb = 'contains'
@ -95,7 +95,7 @@ class HarvestProjectView(HarvestMasterView):
return 'warning' return 'warning'
def configure_form(self, f): def configure_form(self, f):
super(HarvestProjectView, self).configure_form(f) super().configure_form(f)
f.set_type('hourly_rate', 'currency') f.set_type('hourly_rate', 'currency')
@ -108,7 +108,7 @@ class HarvestProjectView(HarvestMasterView):
f.set_readonly('updated_at') f.set_readonly('updated_at')
def get_xref_buttons(self, project): def get_xref_buttons(self, project):
buttons = super(HarvestProjectView, self).get_xref_buttons(project) buttons = super().get_xref_buttons(project)
model = self.model model = self.model
# harvest # harvest
@ -122,8 +122,8 @@ class HarvestProjectView(HarvestMasterView):
def get_row_data(self, project): def get_row_data(self, project):
model = self.model model = self.model
return self.Session.query(model.HarvestTimeEntry)\ return self.Session.query(model.HarvestCacheTimeEntry)\
.filter(model.HarvestTimeEntry.project == project) .filter(model.HarvestCacheTimeEntry.project == project)
def get_parent(self, entry): def get_parent(self, entry):
return entry.project return entry.project
@ -132,8 +132,8 @@ class HarvestProjectView(HarvestMasterView):
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()
HarvestProjectView = kwargs.get('HarvestProjectView', base['HarvestProjectView']) HarvestCacheProjectView = kwargs.get('HarvestCacheProjectView', base['HarvestCacheProjectView'])
HarvestProjectView.defaults(config) HarvestCacheProjectView.defaults(config)
def includeme(config): def includeme(config):

View file

@ -24,17 +24,17 @@
Harvest Task views Harvest Task views
""" """
from rattail_harvest.db.model import HarvestTask from rattail_harvest.db.model import HarvestCacheTask
from rattail_harvest.harvest.config import get_harvest_url from rattail_harvest.harvest.config import get_harvest_url
from .master import HarvestMasterView from .master import HarvestMasterView
class HarvestTaskView(HarvestMasterView): class HarvestCacheTaskView(HarvestMasterView):
""" """
Master view for Harvest Tasks Master view for Harvest Tasks
""" """
model_class = HarvestTask model_class = HarvestCacheTask
url_prefix = '/harvest/tasks' url_prefix = '/harvest/tasks'
route_prefix = 'harvest.tasks' route_prefix = 'harvest.tasks'
@ -48,7 +48,7 @@ class HarvestTaskView(HarvestMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(HarvestTaskView, self).configure_grid(g) super().configure_grid(g)
g.set_sort_defaults('name') g.set_sort_defaults('name')
@ -56,13 +56,13 @@ class HarvestTaskView(HarvestMasterView):
g.set_link('name') g.set_link('name')
def configure_form(self, f): def configure_form(self, f):
super(HarvestTaskView, self).configure_form(f) super().configure_form(f)
# time_entries # time_entries
f.remove_field('time_entries') f.remove_field('time_entries')
def get_xref_buttons(self, task): def get_xref_buttons(self, task):
buttons = super(HarvestTaskView, self).get_xref_buttons(task) buttons = super().get_xref_buttons(task)
model = self.model model = self.model
# harvest # harvest
@ -78,8 +78,8 @@ class HarvestTaskView(HarvestMasterView):
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()
HarvestTaskView = kwargs.get('HarvestTaskView', base['HarvestTaskView']) HarvestCacheTaskView = kwargs.get('HarvestCacheTaskView', base['HarvestCacheTaskView'])
HarvestTaskView.defaults(config) HarvestCacheTaskView.defaults(config)
def includeme(config): def includeme(config):

View file

@ -24,17 +24,17 @@
Harvest Time Entry views Harvest Time Entry views
""" """
from rattail_harvest.db.model import HarvestTimeEntry from rattail_harvest.db.model import HarvestCacheTimeEntry
from rattail_harvest.harvest.config import get_harvest_url from rattail_harvest.harvest.config import get_harvest_url
from .master import HarvestMasterView from .master import HarvestMasterView
class HarvestTimeEntryView(HarvestMasterView): class HarvestCacheTimeEntryView(HarvestMasterView):
""" """
Master view for Harvest Time Entries Master view for Harvest Time Entries
""" """
model_class = HarvestTimeEntry model_class = HarvestCacheTimeEntry
url_prefix = '/harvest/time-entries' url_prefix = '/harvest/time-entries'
route_prefix = 'harvest.time_entries' route_prefix = 'harvest.time_entries'
@ -50,7 +50,7 @@ class HarvestTimeEntryView(HarvestMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(HarvestTimeEntryView, self).configure_grid(g) super().configure_grid(g)
g.set_type('hours', 'duration_hours') g.set_type('hours', 'duration_hours')
@ -99,7 +99,7 @@ class HarvestTimeEntryView(HarvestMasterView):
return f"{hours} ({duration})" return f"{hours} ({duration})"
def get_xref_buttons(self, entry): def get_xref_buttons(self, entry):
buttons = super(HarvestTimeEntryView, self).get_xref_buttons(entry) buttons = super().get_xref_buttons(entry)
model = self.model model = self.model
# harvest # harvest
@ -117,7 +117,7 @@ class HarvestTimeEntryView(HarvestMasterView):
def import_from_harvest(self): def import_from_harvest(self):
app = self.get_rattail_app() app = self.get_rattail_app()
handler = app.get_import_handler('to_rattail.from_harvest.import', require=True) handler = app.get_import_handler('to_rattail.from_harvest.import', require=True)
importer = handler.get_importer('HarvestTimeEntry') importer = handler.get_importer('HarvestCacheTimeEntry')
importer.session = self.Session() importer.session = self.Session()
importer.setup() importer.setup()
@ -155,8 +155,8 @@ class HarvestTimeEntryView(HarvestMasterView):
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()
HarvestTimeEntryView = kwargs.get('HarvestTimeEntryView', base['HarvestTimeEntryView']) HarvestCacheTimeEntryView = kwargs.get('HarvestCacheTimeEntryView', base['HarvestCacheTimeEntryView'])
HarvestTimeEntryView.defaults(config) HarvestCacheTimeEntryView.defaults(config)
def includeme(config): def includeme(config):

View file

@ -24,7 +24,7 @@
Harvest User views Harvest User views
""" """
from rattail_harvest.db.model import HarvestUser from rattail_harvest.db.model import HarvestCacheUser
from rattail_harvest.harvest.config import get_harvest_url from rattail_harvest.harvest.config import get_harvest_url
import colander import colander
@ -33,11 +33,11 @@ from tailbone import forms
from .master import HarvestMasterView from .master import HarvestMasterView
class HarvestUserView(HarvestMasterView): class HarvestCacheUserView(HarvestMasterView):
""" """
Master view for Harvest Users Master view for Harvest Users
""" """
model_class = HarvestUser model_class = HarvestCacheUser
url_prefix = '/harvest/users' url_prefix = '/harvest/users'
route_prefix = 'harvest.users' route_prefix = 'harvest.users'
@ -56,7 +56,7 @@ class HarvestUserView(HarvestMasterView):
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(HarvestUserView, self).configure_grid(g) super().configure_grid(g)
model = self.model model = self.model
g.set_joiner('person_name', lambda q: q.outerjoin(model.Person)) g.set_joiner('person_name', lambda q: q.outerjoin(model.Person))
@ -70,7 +70,7 @@ class HarvestUserView(HarvestMasterView):
g.set_link('email') g.set_link('email')
def configure_form(self, f): def configure_form(self, f):
super(HarvestUserView, self).configure_form(f) super().configure_form(f)
model = self.model model = self.model
user = f.model_instance user = f.model_instance
@ -121,7 +121,7 @@ class HarvestUserView(HarvestMasterView):
raise colander.Invalid(node, "Person not found (you must *select* a record)") raise colander.Invalid(node, "Person not found (you must *select* a record)")
def get_xref_buttons(self, user): def get_xref_buttons(self, user):
buttons = super(HarvestUserView, self).get_xref_buttons(user) buttons = super().get_xref_buttons(user)
model = self.model model = self.model
# harvest proper # harvest proper
@ -136,8 +136,8 @@ class HarvestUserView(HarvestMasterView):
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()
HarvestUserView = kwargs.get('HarvestUserView', base['HarvestUserView']) HarvestCacheUserView = kwargs.get('HarvestCacheUserView', base['HarvestCacheUserView'])
HarvestUserView.defaults(config) HarvestCacheUserView.defaults(config)
def includeme(config): def includeme(config):