Refactor per rename of Harvest cache models
This commit is contained in:
parent
f388f2d6cf
commit
eb904aea3b
|
@ -24,7 +24,7 @@
|
|||
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 webhelpers2.html import HTML, tags
|
||||
|
@ -32,11 +32,11 @@ from webhelpers2.html import HTML, tags
|
|||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestClientView(HarvestMasterView):
|
||||
class HarvestCacheClientView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Clients
|
||||
"""
|
||||
model_class = HarvestClient
|
||||
model_class = HarvestCacheClient
|
||||
url_prefix = '/harvest/clients'
|
||||
route_prefix = 'harvest.clients'
|
||||
|
||||
|
@ -47,7 +47,7 @@ class HarvestClientView(HarvestMasterView):
|
|||
]
|
||||
|
||||
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_verb = 'contains'
|
||||
|
@ -65,7 +65,7 @@ class HarvestClientView(HarvestMasterView):
|
|||
return 'warning'
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestClientView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
# projects
|
||||
f.set_renderer('projects', self.render_projects)
|
||||
|
@ -86,7 +86,7 @@ class HarvestClientView(HarvestMasterView):
|
|||
return HTML.tag('ul', c=items)
|
||||
|
||||
def get_xref_buttons(self, client):
|
||||
buttons = super(HarvestClientView, self).get_xref_buttons(client)
|
||||
buttons = super().get_xref_buttons(client)
|
||||
model = self.model
|
||||
|
||||
# harvest proper
|
||||
|
@ -102,8 +102,8 @@ class HarvestClientView(HarvestMasterView):
|
|||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
HarvestClientView = kwargs.get('HarvestClientView', base['HarvestClientView'])
|
||||
HarvestClientView.defaults(config)
|
||||
HarvestCacheClientView = kwargs.get('HarvestCacheClientView', base['HarvestCacheClientView'])
|
||||
HarvestCacheClientView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
Harvest master view
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestTimeEntry
|
||||
from rattail_harvest.db.model import HarvestCacheTimeEntry
|
||||
|
||||
from webhelpers2.html import tags
|
||||
|
||||
|
@ -38,7 +38,7 @@ class HarvestMasterView(MasterView):
|
|||
creatable = False
|
||||
touchable = True
|
||||
has_versions = True
|
||||
model_row_class = HarvestTimeEntry
|
||||
model_row_class = HarvestCacheTimeEntry
|
||||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
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 .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestProjectView(HarvestMasterView):
|
||||
class HarvestCacheProjectView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Projects
|
||||
"""
|
||||
model_class = HarvestProject
|
||||
model_class = HarvestCacheProject
|
||||
url_prefix = '/harvest/projects'
|
||||
route_prefix = 'harvest.projects'
|
||||
|
||||
|
@ -62,12 +62,12 @@ class HarvestProjectView(HarvestMasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestProjectView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
model = self.model
|
||||
|
||||
g.set_joiner('client', lambda q: q.outerjoin(model.HarvestClient))
|
||||
g.set_sorter('client', model.HarvestClient.name)
|
||||
g.set_filter('client', model.HarvestClient.name, label="Client Name")
|
||||
g.set_joiner('client', lambda q: q.outerjoin(model.HarvestCacheClient))
|
||||
g.set_sorter('client', model.HarvestCacheClient.name)
|
||||
g.set_filter('client', model.HarvestCacheClient.name, label="Client Name")
|
||||
g.filters['client'].default_active = True
|
||||
g.filters['client'].default_verb = 'contains'
|
||||
|
||||
|
@ -95,7 +95,7 @@ class HarvestProjectView(HarvestMasterView):
|
|||
return 'warning'
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestProjectView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
f.set_type('hourly_rate', 'currency')
|
||||
|
||||
|
@ -108,7 +108,7 @@ class HarvestProjectView(HarvestMasterView):
|
|||
f.set_readonly('updated_at')
|
||||
|
||||
def get_xref_buttons(self, project):
|
||||
buttons = super(HarvestProjectView, self).get_xref_buttons(project)
|
||||
buttons = super().get_xref_buttons(project)
|
||||
model = self.model
|
||||
|
||||
# harvest
|
||||
|
@ -122,8 +122,8 @@ class HarvestProjectView(HarvestMasterView):
|
|||
|
||||
def get_row_data(self, project):
|
||||
model = self.model
|
||||
return self.Session.query(model.HarvestTimeEntry)\
|
||||
.filter(model.HarvestTimeEntry.project == project)
|
||||
return self.Session.query(model.HarvestCacheTimeEntry)\
|
||||
.filter(model.HarvestCacheTimeEntry.project == project)
|
||||
|
||||
def get_parent(self, entry):
|
||||
return entry.project
|
||||
|
@ -132,8 +132,8 @@ class HarvestProjectView(HarvestMasterView):
|
|||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
HarvestProjectView = kwargs.get('HarvestProjectView', base['HarvestProjectView'])
|
||||
HarvestProjectView.defaults(config)
|
||||
HarvestCacheProjectView = kwargs.get('HarvestCacheProjectView', base['HarvestCacheProjectView'])
|
||||
HarvestCacheProjectView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
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 .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestTaskView(HarvestMasterView):
|
||||
class HarvestCacheTaskView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Tasks
|
||||
"""
|
||||
model_class = HarvestTask
|
||||
model_class = HarvestCacheTask
|
||||
url_prefix = '/harvest/tasks'
|
||||
route_prefix = 'harvest.tasks'
|
||||
|
||||
|
@ -48,7 +48,7 @@ class HarvestTaskView(HarvestMasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestTaskView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
|
||||
g.set_sort_defaults('name')
|
||||
|
||||
|
@ -56,13 +56,13 @@ class HarvestTaskView(HarvestMasterView):
|
|||
g.set_link('name')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestTaskView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
|
||||
# time_entries
|
||||
f.remove_field('time_entries')
|
||||
|
||||
def get_xref_buttons(self, task):
|
||||
buttons = super(HarvestTaskView, self).get_xref_buttons(task)
|
||||
buttons = super().get_xref_buttons(task)
|
||||
model = self.model
|
||||
|
||||
# harvest
|
||||
|
@ -78,8 +78,8 @@ class HarvestTaskView(HarvestMasterView):
|
|||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
HarvestTaskView = kwargs.get('HarvestTaskView', base['HarvestTaskView'])
|
||||
HarvestTaskView.defaults(config)
|
||||
HarvestCacheTaskView = kwargs.get('HarvestCacheTaskView', base['HarvestCacheTaskView'])
|
||||
HarvestCacheTaskView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
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 .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestTimeEntryView(HarvestMasterView):
|
||||
class HarvestCacheTimeEntryView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Time Entries
|
||||
"""
|
||||
model_class = HarvestTimeEntry
|
||||
model_class = HarvestCacheTimeEntry
|
||||
url_prefix = '/harvest/time-entries'
|
||||
route_prefix = 'harvest.time_entries'
|
||||
|
||||
|
@ -50,7 +50,7 @@ class HarvestTimeEntryView(HarvestMasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestTimeEntryView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
|
||||
g.set_type('hours', 'duration_hours')
|
||||
|
||||
|
@ -99,7 +99,7 @@ class HarvestTimeEntryView(HarvestMasterView):
|
|||
return f"{hours} ({duration})"
|
||||
|
||||
def get_xref_buttons(self, entry):
|
||||
buttons = super(HarvestTimeEntryView, self).get_xref_buttons(entry)
|
||||
buttons = super().get_xref_buttons(entry)
|
||||
model = self.model
|
||||
|
||||
# harvest
|
||||
|
@ -117,7 +117,7 @@ class HarvestTimeEntryView(HarvestMasterView):
|
|||
def import_from_harvest(self):
|
||||
app = self.get_rattail_app()
|
||||
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.setup()
|
||||
|
||||
|
@ -155,8 +155,8 @@ class HarvestTimeEntryView(HarvestMasterView):
|
|||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
HarvestTimeEntryView = kwargs.get('HarvestTimeEntryView', base['HarvestTimeEntryView'])
|
||||
HarvestTimeEntryView.defaults(config)
|
||||
HarvestCacheTimeEntryView = kwargs.get('HarvestCacheTimeEntryView', base['HarvestCacheTimeEntryView'])
|
||||
HarvestCacheTimeEntryView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
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
|
||||
|
||||
import colander
|
||||
|
@ -33,11 +33,11 @@ from tailbone import forms
|
|||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestUserView(HarvestMasterView):
|
||||
class HarvestCacheUserView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Users
|
||||
"""
|
||||
model_class = HarvestUser
|
||||
model_class = HarvestCacheUser
|
||||
url_prefix = '/harvest/users'
|
||||
route_prefix = 'harvest.users'
|
||||
|
||||
|
@ -56,7 +56,7 @@ class HarvestUserView(HarvestMasterView):
|
|||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestUserView, self).configure_grid(g)
|
||||
super().configure_grid(g)
|
||||
model = self.model
|
||||
|
||||
g.set_joiner('person_name', lambda q: q.outerjoin(model.Person))
|
||||
|
@ -70,7 +70,7 @@ class HarvestUserView(HarvestMasterView):
|
|||
g.set_link('email')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestUserView, self).configure_form(f)
|
||||
super().configure_form(f)
|
||||
model = self.model
|
||||
user = f.model_instance
|
||||
|
||||
|
@ -121,7 +121,7 @@ class HarvestUserView(HarvestMasterView):
|
|||
raise colander.Invalid(node, "Person not found (you must *select* a record)")
|
||||
|
||||
def get_xref_buttons(self, user):
|
||||
buttons = super(HarvestUserView, self).get_xref_buttons(user)
|
||||
buttons = super().get_xref_buttons(user)
|
||||
model = self.model
|
||||
|
||||
# harvest proper
|
||||
|
@ -136,8 +136,8 @@ class HarvestUserView(HarvestMasterView):
|
|||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
HarvestUserView = kwargs.get('HarvestUserView', base['HarvestUserView'])
|
||||
HarvestUserView.defaults(config)
|
||||
HarvestCacheUserView = kwargs.get('HarvestCacheUserView', base['HarvestCacheUserView'])
|
||||
HarvestCacheUserView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
Loading…
Reference in a new issue