Initial commit; w/ views for cache tables
This commit is contained in:
commit
455027c5d0
19 changed files with 744 additions and 0 deletions
0
tailbone_harvest/views/__init__.py
Normal file
0
tailbone_harvest/views/__init__.py
Normal file
35
tailbone_harvest/views/harvest/__init__.py
Normal file
35
tailbone_harvest/views/harvest/__init__.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest Views
|
||||
"""
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
def includeme(config):
|
||||
config.include('tailbone_harvest.views.harvest.users')
|
||||
config.include('tailbone_harvest.views.harvest.clients')
|
||||
config.include('tailbone_harvest.views.harvest.projects')
|
||||
config.include('tailbone_harvest.views.harvest.tasks')
|
||||
config.include('tailbone_harvest.views.harvest.time_entries')
|
82
tailbone_harvest/views/harvest/clients.py
Normal file
82
tailbone_harvest/views/harvest/clients.py
Normal file
|
@ -0,0 +1,82 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest Client views
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestClient
|
||||
|
||||
from webhelpers2.html import HTML, tags
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestClientView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Clients
|
||||
"""
|
||||
model_class = HarvestClient
|
||||
url_prefix = '/harvest/clients'
|
||||
route_prefix = 'harvest.clients'
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'currency',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestClientView, self).configure_grid(g)
|
||||
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
|
||||
g.set_sort_defaults('name')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('name')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestClientView, self).configure_form(f)
|
||||
|
||||
# projects
|
||||
f.set_renderer('projects', self.render_projects)
|
||||
|
||||
# time_entries
|
||||
f.remove_field('time_entries')
|
||||
|
||||
def render_projects(self, client, field):
|
||||
projects = client.projects
|
||||
if not projects:
|
||||
return
|
||||
|
||||
items = []
|
||||
for project in projects:
|
||||
text = "({}) {}".format(project.code, project.name)
|
||||
url = self.request.route_url('harvest.projects.view', uuid=project.uuid)
|
||||
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
||||
return HTML.tag('ul', c=items)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestClientView.defaults(config)
|
41
tailbone_harvest/views/harvest/master.py
Normal file
41
tailbone_harvest/views/harvest/master.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest master view
|
||||
"""
|
||||
|
||||
from tailbone.views import MasterView
|
||||
|
||||
|
||||
class HarvestMasterView(MasterView):
|
||||
"""
|
||||
Base class for Harvest master views
|
||||
"""
|
||||
creatable = False
|
||||
editable = False
|
||||
deletable = False
|
||||
has_versions = True
|
||||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
}
|
74
tailbone_harvest/views/harvest/projects.py
Normal file
74
tailbone_harvest/views/harvest/projects.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest Project views
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestProject
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestProjectView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Projects
|
||||
"""
|
||||
model_class = HarvestProject
|
||||
url_prefix = '/harvest/projects'
|
||||
route_prefix = 'harvest.projects'
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'client',
|
||||
'name',
|
||||
'code',
|
||||
'is_active',
|
||||
'is_billable',
|
||||
'bill_by',
|
||||
'hourly_rate',
|
||||
'fee',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestProjectView, self).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.filters['client'].default_active = True
|
||||
g.filters['client'].default_verb = 'contains'
|
||||
|
||||
g.set_type('hourly_rate', 'currency')
|
||||
g.set_type('fee', 'currency')
|
||||
|
||||
g.set_sort_defaults('client')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('client')
|
||||
g.set_link('name')
|
||||
g.set_link('code')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestProjectView.defaults(config)
|
65
tailbone_harvest/views/harvest/tasks.py
Normal file
65
tailbone_harvest/views/harvest/tasks.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest Task views
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestTask
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestTaskView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Tasks
|
||||
"""
|
||||
model_class = HarvestTask
|
||||
url_prefix = '/harvest/tasks'
|
||||
route_prefix = 'harvest.tasks'
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'name',
|
||||
'billable_by_default',
|
||||
'default_hourly_rate',
|
||||
'is_default',
|
||||
'is_active',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestTaskView, self).configure_grid(g)
|
||||
|
||||
g.set_sort_defaults('name')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('name')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestTaskView, self).configure_form(f)
|
||||
|
||||
# time_entries
|
||||
f.remove_field('time_entries')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestTaskView.defaults(config)
|
73
tailbone_harvest/views/harvest/time_entries.py
Normal file
73
tailbone_harvest/views/harvest/time_entries.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest Time Entry views
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestTimeEntry
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestTimeEntryView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Time Entries
|
||||
"""
|
||||
model_class = HarvestTimeEntry
|
||||
url_prefix = '/harvest/time-entries'
|
||||
route_prefix = 'harvest.time_entries'
|
||||
|
||||
labels = {
|
||||
'user_id': "User ID",
|
||||
'client_id': "Client ID",
|
||||
'project_id': "Project ID",
|
||||
'task_id': "Task ID",
|
||||
'invoice_id': "Invoice ID",
|
||||
}
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'spent_date',
|
||||
'user',
|
||||
'client',
|
||||
'project',
|
||||
'task',
|
||||
'hours',
|
||||
'notes',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestTimeEntryView, self).configure_grid(g)
|
||||
|
||||
g.set_type('hours', 'duration_hours')
|
||||
|
||||
g.set_sort_defaults('spent_date', 'desc')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('user')
|
||||
g.set_link('client')
|
||||
g.set_link('notes')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestTimeEntryView.defaults(config)
|
68
tailbone_harvest/views/harvest/users.py
Normal file
68
tailbone_harvest/views/harvest/users.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Harvest User views
|
||||
"""
|
||||
|
||||
from rattail_harvest.db.model import HarvestUser
|
||||
|
||||
from .master import HarvestMasterView
|
||||
|
||||
|
||||
class HarvestUserView(HarvestMasterView):
|
||||
"""
|
||||
Master view for Harvest Users
|
||||
"""
|
||||
model_class = HarvestUser
|
||||
url_prefix = '/harvest/users'
|
||||
route_prefix = 'harvest.users'
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'telephone',
|
||||
'timezone',
|
||||
'is_admin',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(HarvestUserView, self).configure_grid(g)
|
||||
|
||||
g.set_sort_defaults('first_name')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('first_name')
|
||||
g.set_link('last_name')
|
||||
g.set_link('email')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(HarvestUserView, self).configure_form(f)
|
||||
|
||||
# TODO: should add this as child rows/grid instead
|
||||
f.remove('time_entries')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
HarvestUserView.defaults(config)
|
Loading…
Add table
Add a link
Reference in a new issue