diff --git a/rattail_demo/config.py b/rattail_demo/config.py index 1ff335b..8cd6ccb 100644 --- a/rattail_demo/config.py +++ b/rattail_demo/config.py @@ -18,3 +18,4 @@ class DemoConfigExtension(ConfigExtension): # tell rattail where our stuff lives config.setdefault('rattail.mail', 'emails', 'rattail_demo.emails') + config.setdefault('tailbone', 'menus', 'rattail_demo.web.menus') diff --git a/rattail_demo/web/menus.py b/rattail_demo/web/menus.py new file mode 100644 index 0000000..37a818a --- /dev/null +++ b/rattail_demo/web/menus.py @@ -0,0 +1,232 @@ +# -*- coding: utf-8; -*- +""" +Web Menus +""" + +from __future__ import unicode_literals, absolute_import + + +def simple_menus(request): + url = request.route_url + + menus = [ + { + 'title': "Time Clock", + 'type': 'menu', + 'items': [ + { + 'title': "Personal Schedule", + 'url': url('schedule.employee'), + 'perm': 'schedule.view', + }, + { + 'title': "Full Schedule", + 'url': url('schedule'), + 'perm': 'schedule.viewall', + }, + { + 'title': "Edit Schedule", + 'url': url('schedule.edit'), + 'perm': 'schedule.edit', + }, + { + 'title': "Raw Scheduled Shifts", + 'url': url('scheduledshifts'), + 'perm': 'scheduledshifts.list', + }, + ], + }, + { + 'title': "Products", + 'type': 'menu', + 'items': [ + { + 'title': "Products", + 'url': url('products'), + 'perm': 'products.list', + }, + { + 'title': "Vendors", + 'url': url('vendors'), + 'perm': 'vendors.list', + }, + { + 'title': "Departments", + 'url': url('departments'), + 'perm': 'departments.list', + }, + { + 'title': "Subdepartments", + 'url': url('subdepartments'), + 'perm': 'subdepartments.list', + }, + { + 'title': "Brands", + 'url': url('brands'), + 'perm': 'brands.list', + }, + { + 'title': "Families", + 'url': url('families'), + 'perm': 'families.list', + }, + { + 'title': "Report Codes", + 'url': url('reportcodes'), + 'perm': 'reportcodes.list', + }, + ], + }, + { + 'title': "People", + 'type': 'menu', + 'items': [ + { + 'title': "All People", + 'url': url('people'), + 'perm': 'people.list', + }, + { + 'title': "Customers", + 'url': url('customers'), + 'perm': 'customers.list', + }, + { + 'title': "Employees", + 'url': url('employees'), + 'perm': 'employees.list', + }, + ], + }, + { + 'title': "CORE-POS", + 'type': 'menu', + 'items': [ + { + 'title': "Departments", + 'url': url('corepos.departments'), + 'perm': 'corepos.departments.list', + }, + { + 'title': "Subdepartments", + 'url': url('corepos.subdepartments'), + 'perm': 'corepos.subdepartments.list', + }, + { + 'title': "Vendors", + 'url': url('corepos.vendors'), + 'perm': 'corepos.vendors.list', + }, + { + 'title': "Products", + 'url': url('corepos.products'), + 'perm': 'corepos.products.list', + }, + { + 'title': "Customers", + 'url': url('corepos.customers'), + 'perm': 'corepos.customers.list', + }, + { + 'title': "Employees", + 'url': url('corepos.employees'), + 'perm': 'corepos.employees.list', + }, + { + 'title': "Transaction Details", + 'url': url('corepos.transaction_details'), + 'perm': 'corepos.transaction_details.list', + }, + ], + }, + { + 'title': "Batches", + 'type': 'menu', + 'items': [ + { + 'title': "Handheld", + 'url': url('batch.handheld'), + 'perm': 'batch.handheld.list', + }, + { + 'title': "Inventory", + 'url': url('batch.inventory'), + 'perm': 'batch.inventory.list', + }, + { + 'title': "Import / Export", + 'url': url('batch.importer'), + 'perm': 'batch.importer.list', + }, + ], + }, + { + 'title': "TempMon", + 'type': 'menu', + 'items': [ + { + 'title': "Clients", + 'url': url('tempmon.clients'), + 'perm': 'tempmon.clients.list', + }, + { + 'title': "Probes", + 'url': url('tempmon.probes'), + 'perm': 'tempmon.probes.list', + }, + { + 'title': "Readings", + 'url': url('tempmon.readings'), + 'perm': 'tempmon.readings.list', + }, + ], + }, + { + 'title': "Admin", + 'type': 'menu', + 'items': [ + { + 'title': "Stores", + 'url': url('stores'), + 'perm': 'stores.list', + }, + { + 'title': "Users", + 'url': url('users'), + 'perm': 'users.list', + }, + { + 'title': "User Events", + 'url': url('userevents'), + 'perm': 'userevents.list', + }, + { + 'title': "Roles", + 'url': url('roles'), + 'perm': 'roles.list', + }, + { + 'title': "Email Settings", + 'url': url('emailprofiles'), + 'perm': 'emailprofiles.list', + }, + { + 'title': "Raw Settings", + 'url': url('settings'), + 'perm': 'settings.list', + }, + { + 'title': "DataSync Changes", + 'url': url('datasyncchanges'), + 'perm': 'datasync.list', + }, + { + 'title': "Rattail Demo Upgrades", + 'url': url('upgrades'), + 'perm': 'upgrades.list', + }, + ], + }, + ] + + return menus diff --git a/rattail_demo/web/templates/menu.mako b/rattail_demo/web/templates/menu.mako index d8bdad0..966e724 100644 --- a/rattail_demo/web/templates/menu.mako +++ b/rattail_demo/web/templates/menu.mako @@ -1,161 +1,58 @@ ## -*- coding: utf-8; -*- +<%def name="make_simple_menu()"> + + % for topitem in menus: +
  • + ${topitem.title} + +
  • + % endfor + + ## User Menu + % if request.user: +
  • + ${request.user}${" ({})".format(inbox_count) if inbox_count else ''} + +
  • + % else: +
  • ${h.link_to("Login", url('login'))}
  • + % endif + + + <%def name="main_menu_items()"> - % if request.has_any_perm('schedule.view', 'schedule.viewall', 'schedule.edit', 'scheduledshifts.list'): -
  • - Time Clock - -
  • - % endif + % if request.rattail_config.getbool('tailbone', 'menus.simple', default=False): + ${self.make_simple_menu()} + % else: - % if request.has_any_perm('products.list', 'vendors.list', 'departments.list', 'subdepartments.list', 'brands.list', 'families.list', 'reportcodes.list'): -
  • - Products - -
  • - % endif - - % if request.has_any_perm('people.list', 'customers.list', 'employees.list'): -
  • - People - -
  • - % endif - - % if request.has_any_perm('corepos.departments.list', 'corepos.subdepartments.list', 'corepos.vendors.list', 'corepos.products.list', 'corepos.customers.list', 'corepos.employees.list', 'corepos.transaction_details.list'): -
  • - CORE-POS - -
  • - % endif - - % if request.has_any_perm('batch.handheld.list', 'batch.inventory.list', 'batch.importer.list'): -
  • - Batches - -
  • - % endif - - % if request.has_any_perm('tempmon.clients.list', 'tempmon.probes.list', 'tempmon.readings.list'): -
  • - TempMon - -
  • - % endif - - % if request.has_any_perm('stores.list', 'users.list', 'userevents.list', 'roles.list', 'emailprofiles.list', 'datasync.list', 'settings.list', 'upgrades.list'): + % if request.has_any_perm('users.list', 'roles.list', 'settings.list', 'upgrades.list'):
  • Admin