From fcb21b9671e9ff1d98dd1e91a090d13ddb822fa8 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 10 Dec 2016 16:04:34 -0600 Subject: [PATCH] Add initial support for employee schedule views --- rattail_demo/web/templates/menu.mako | 20 +++++++++++++++++++ rattail_demo/web/views/__init__.py | 3 ++- rattail_demo/web/views/employees.py | 30 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 rattail_demo/web/views/employees.py diff --git a/rattail_demo/web/templates/menu.mako b/rattail_demo/web/templates/menu.mako index b3d0807..e330925 100644 --- a/rattail_demo/web/templates/menu.mako +++ b/rattail_demo/web/templates/menu.mako @@ -2,6 +2,26 @@ <%def name="main_menu_items()"> + % if request.has_any_perm('schedule.view', 'schedule.viewall', 'schedule.edit', 'scheduledshifts.list'): +
  • + Time Clock + +
  • + % endif + % if request.has_any_perm('products.list', 'vendors.list', 'brands.list', 'families.list', 'reportcodes.list'):
  • Products diff --git a/rattail_demo/web/views/__init__.py b/rattail_demo/web/views/__init__.py index 1819d94..b4c2f3d 100644 --- a/rattail_demo/web/views/__init__.py +++ b/rattail_demo/web/views/__init__.py @@ -34,7 +34,7 @@ def includeme(config): config.include('tailbone.views.customers') config.include('tailbone.views.departments') config.include('rattail_demo.web.views.email') - config.include('tailbone.views.employees') + config.include('rattail_demo.web.views.employees') config.include('tailbone.views.families') config.include('tailbone.views.messages') config.include('rattail_demo.web.views.people') @@ -42,6 +42,7 @@ def includeme(config): config.include('tailbone.views.reportcodes') config.include('tailbone.views.roles') config.include('rattail_demo.web.views.settings') + config.include('tailbone.views.shifts') config.include('tailbone.views.stores') config.include('tailbone.views.subdepartments') config.include('rattail_demo.web.views.tempmon') diff --git a/rattail_demo/web/views/employees.py b/rattail_demo/web/views/employees.py new file mode 100644 index 0000000..5fc99ae --- /dev/null +++ b/rattail_demo/web/views/employees.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +""" +Employee views +""" + +from __future__ import unicode_literals, absolute_import + +from tailbone.views import employees as base + + +class EmployeesView(base.EmployeesView): + """ + Prevent edit/delete for Chuck Norris + """ + + def editable_instance(self, employee): + return employee.person_uuid != '30d1fe06bcf411e6a7c23ca9f40bc550' + + def deletable_instance(self, employee): + return employee.person_uuid != '30d1fe06bcf411e6a7c23ca9f40bc550' + + +def includeme(config): + + # autocomplete + config.add_route('employees.autocomplete', '/employees/autocomplete') + config.add_view(base.EmployeesAutocomplete, route_name='employees.autocomplete', + renderer='json', permission='employees.list') + + EmployeesView.defaults(config)