Cleanup views for Harvest Projects
This commit is contained in:
parent
c874281f33
commit
14e021db0d
|
@ -24,6 +24,8 @@
|
|||
Harvest master view
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestTimeEntry
|
||||
|
||||
from tailbone.views import MasterView
|
||||
|
||||
|
||||
|
@ -33,9 +35,24 @@ class HarvestMasterView(MasterView):
|
|||
"""
|
||||
creatable = False
|
||||
editable = False
|
||||
deletable = False
|
||||
has_versions = True
|
||||
model_row_class = HarvestTimeEntry
|
||||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
}
|
||||
|
||||
row_labels = {
|
||||
'id': "ID",
|
||||
}
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestMasterView, self).configure_form(f)
|
||||
f.remove('time_entries')
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
super(HarvestMasterView, self).configure_row_grid(g)
|
||||
g.set_sort_defaults('spent_date', 'desc')
|
||||
|
||||
def row_view_action_url(self, entry, i):
|
||||
return self.request.route_url('harvest.time_entries.view', uuid=entry.uuid)
|
||||
|
|
|
@ -37,6 +37,8 @@ class HarvestProjectView(HarvestMasterView):
|
|||
url_prefix = '/harvest/projects'
|
||||
route_prefix = 'harvest.projects'
|
||||
|
||||
has_rows = True
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'client',
|
||||
|
@ -49,6 +51,15 @@ class HarvestProjectView(HarvestMasterView):
|
|||
'fee',
|
||||
]
|
||||
|
||||
row_grid_columns = [
|
||||
'id',
|
||||
'spent_date',
|
||||
'user',
|
||||
'client',
|
||||
'task',
|
||||
'hours',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestProjectView, self).configure_grid(g)
|
||||
model = self.model
|
||||
|
@ -59,6 +70,9 @@ class HarvestProjectView(HarvestMasterView):
|
|||
g.filters['client'].default_active = True
|
||||
g.filters['client'].default_verb = 'contains'
|
||||
|
||||
g.filters['is_active'].default_active = True
|
||||
g.filters['is_active'].default_verb = 'is_true'
|
||||
|
||||
g.set_type('hourly_rate', 'currency')
|
||||
g.set_type('fee', 'currency')
|
||||
|
||||
|
@ -69,6 +83,18 @@ class HarvestProjectView(HarvestMasterView):
|
|||
g.set_link('name')
|
||||
g.set_link('code')
|
||||
|
||||
def grid_extra_class(self, project, i):
|
||||
if not project.is_active:
|
||||
return 'warning'
|
||||
|
||||
def get_row_data(self, project):
|
||||
model = self.model
|
||||
return self.Session.query(model.HarvestTimeEntry)\
|
||||
.filter(model.HarvestTimeEntry.project == project)
|
||||
|
||||
def get_parent(self, entry):
|
||||
return entry.project
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestProjectView.defaults(config)
|
||||
|
|
Loading…
Reference in a new issue