Misc. tweaks to improve viewing Harvest cache records

This commit is contained in:
Lance Edgar 2022-03-09 19:43:18 -06:00
parent f3e05124c3
commit 8da3f89524
6 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,16 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="page_content()">
% if instance.avatar_url:
<div style="margin: 1rem;">
<img src="${instance.avatar_url}" />
</div>
% endif
${parent.page_content()}
</%def>
${parent.body()}

View file

@ -26,6 +26,8 @@ Harvest master view
from rattail_harvest.db.model import HarvestTimeEntry from rattail_harvest.db.model import HarvestTimeEntry
from webhelpers2.html import tags
from tailbone.views import MasterView from tailbone.views import MasterView
@ -54,6 +56,34 @@ class HarvestMasterView(MasterView):
super(HarvestMasterView, self).configure_form(f) super(HarvestMasterView, self).configure_form(f)
f.remove('time_entries') f.remove('time_entries')
def render_harvest_user(self, obj, field):
user = getattr(obj, field)
if user:
text = str(user)
url = self.request.route_url('harvest.users.view', uuid=user.uuid)
return tags.link_to(text, url)
def render_harvest_client(self, obj, field):
client = getattr(obj, field)
if client:
text = str(client)
url = self.request.route_url('harvest.clients.view', uuid=client.uuid)
return tags.link_to(text, url)
def render_harvest_project(self, obj, field):
project = getattr(obj, field)
if project:
text = str(project)
url = self.request.route_url('harvest.projects.view', uuid=project.uuid)
return tags.link_to(text, url)
def render_harvest_task(self, obj, field):
task = getattr(obj, field)
if task:
text = str(task)
url = self.request.route_url('harvest.tasks.view', uuid=task.uuid)
return tags.link_to(text, url)
def configure_row_grid(self, g): def configure_row_grid(self, g):
super(HarvestMasterView, self).configure_row_grid(g) super(HarvestMasterView, self).configure_row_grid(g)
g.set_sort_defaults('spent_date', 'desc') g.set_sort_defaults('spent_date', 'desc')

View file

@ -96,6 +96,8 @@ class HarvestProjectView(HarvestMasterView):
def configure_form(self, f): def configure_form(self, f):
super(HarvestProjectView, self).configure_form(f) super(HarvestProjectView, self).configure_form(f)
f.set_type('hourly_rate', 'currency')
if self.editing: if self.editing:
f.remove('client') f.remove('client')
f.set_type('over_budget_notification_date', 'date_jquery') f.set_type('over_budget_notification_date', 'date_jquery')

View file

@ -60,6 +60,34 @@ class HarvestTimeEntryView(HarvestMasterView):
g.set_link('client') g.set_link('client')
g.set_link('notes') g.set_link('notes')
def configure_form(self, f):
super(HarvestTimeEntryView, self).configure_form(f)
# make sure id is first field
f.remove('id')
f.insert(0, 'id')
# user
f.remove('user_id')
f.set_renderer('user', self.render_harvest_user)
# client
f.remove('client_id')
f.set_renderer('client', self.render_harvest_client)
# project
f.remove('project_id')
f.set_renderer('project', self.render_harvest_project)
# task
f.remove('task_id')
f.set_renderer('task', self.render_harvest_task)
f.set_type('notes', 'text')
f.set_type('billable_rate', 'currency')
f.set_type('cost_rate', 'currency')
def defaults(config, **kwargs): def defaults(config, **kwargs):
base = globals() base = globals()

View file

@ -40,6 +40,10 @@ class HarvestUserView(HarvestMasterView):
url_prefix = '/harvest/users' url_prefix = '/harvest/users'
route_prefix = 'harvest.users' route_prefix = 'harvest.users'
labels = {
'avatar_url': "Avatar URL",
}
grid_columns = [ grid_columns = [
'id', 'id',
'first_name', 'first_name',
@ -88,6 +92,15 @@ class HarvestUserView(HarvestMasterView):
field_display=person_display, service_url=people_url)) field_display=person_display, service_url=people_url))
f.set_validator('person_uuid', self.valid_person) f.set_validator('person_uuid', self.valid_person)
f.set_label('person_uuid', "Person") f.set_label('person_uuid', "Person")
else:
f.remove('person_uuid')
f.set_type('weekly_capacity', 'duration')
f.set_type('default_hourly_rate', 'currency')
f.set_type('cost_rate', 'currency')
f.set_renderer('avatar_url', self.render_url)
# timestamps # timestamps
if self.creating or self.editing: if self.creating or self.editing: