diff --git a/rattail_demo/config.py b/rattail_demo/config.py index bcaf5d6..6e6d745 100644 --- a/rattail_demo/config.py +++ b/rattail_demo/config.py @@ -18,6 +18,7 @@ class DemoConfigExtension(ConfigExtension): # tell rattail where our stuff lives config.setdefault('rattail', 'model', 'rattail_demo.db.model') + config.setdefault('rattail.trainwreck', 'model', 'rattail.trainwreck.db.model.defaults') 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 index 763fada..2df9ee2 100644 --- a/rattail_demo/web/menus.py +++ b/rattail_demo/web/menus.py @@ -8,270 +8,305 @@ from tailbone_corepos.menus import make_corepos_menu def simple_menus(request): url = request.route_url + rattail_config = request.rattail_config + + people_menu = { + 'title': "People", + 'type': 'menu', + 'items': [ + { + 'title': "Members", + 'url': url('members'), + 'perm': 'members.list', + }, + { + 'title': "Customers", + 'url': url('customers'), + 'perm': 'customers.list', + }, + { + 'title': "Employees", + 'url': url('employees'), + 'perm': 'employees.list', + }, + { + 'title': "All People", + 'url': url('people'), + 'perm': 'people.list', + }, + ], + } + + products_menu = { + 'title': "Products", + 'type': 'menu', + 'items': [ + { + 'title': "Products", + 'url': url('products'), + 'perm': 'products.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': "Units of Measure", + 'url': url('uoms'), + 'perm': 'uoms.list', + }, + ], + } + + vendors_menu = { + 'title': "Vendors", + 'type': 'menu', + 'items': [ + { + 'title': "Vendors", + 'url': url('vendors'), + 'perm': 'vendors.list', + }, + {'type': 'sep'}, + { + 'title': "Ordering", + 'url': url('ordering'), + 'perm': 'ordering.list', + }, + { + 'title': "Receiving", + 'url': url('receiving'), + 'perm': 'receiving.list', + }, + {'type': 'sep'}, + { + 'title': "Purchases", + 'url': url('purchases'), + 'perm': 'purchases.list', + }, + { + 'title': "Credits", + 'url': url('purchases.credits'), + 'perm': 'purchases.credits.list', + }, + ], + } corepos_menu = make_corepos_menu(request) + shopfoo_menu = { + 'title': "Shopfoo", + 'type': 'menu', + 'items': [ + { + 'title': "Products", + 'url': url('shopfoo.products'), + 'perm': 'shopfoo.products.list', + }, + { + 'title': "Product Exports", + 'url': url('shopfoo.product_exports'), + 'perm': 'shopfoo.product_exports.list', + }, + {'type': 'sep'}, + { + 'title': "WooCommerce Products", + 'url': url('woocommerce.products'), + 'perm': 'woocommerce.products.list', + }, + ], + } + + batch_menu = { + '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', + }, + ], + } + + trainwreck_menu = { + 'title': "Trainwreck", + 'type': 'menu', + 'items': [ + { + 'title': "Transactions", + 'url': url('trainwreck.transactions'), + 'perm': 'trainwreck.transactions.list', + }, + ], + } + + tempmon_menu = { + 'title': "TempMon", + 'type': 'menu', + 'items': [ + { + 'title': "Appliances", + 'url': url('tempmon.appliances'), + 'perm': 'tempmon.appliances.list', + }, + { + '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', + }, + ], + } + + other_menu = { + 'title': "Other", + 'type': 'menu', + 'items': [ + { + 'title': "Documentation", + 'url': 'https://rattailproject.org/moin/RattailDemo', + 'target': '_blank', + }, + { + 'title': "Source Code", + 'url': 'https://kallithea.rattailproject.org/rattail-project/rattail-demo', + 'target': '_blank', + }, + { + 'title': "RattailProject.org", + 'url': 'https://rattailproject.org', + 'target': '_blank', + }, + {'type': 'sep'}, + { + 'title': "Generate New Project", + 'url': url('generate_project'), + 'perm': 'common.generate_project', + }, + ], + } + + admin_menu = { + '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', + }, + {'type': 'sep'}, + { + 'title': "App Settings", + 'url': url('appsettings'), + 'perm': 'settings.list', + }, + { + 'title': "Email Settings", + 'url': url('emailprofiles'), + 'perm': 'emailprofiles.list', + }, + { + 'title': "Email Attempts", + 'url': url('email_attempts'), + 'perm': 'email_attempts.list', + }, + { + 'title': "Raw Settings", + 'url': url('settings'), + 'perm': 'settings.list', + }, + {'type': 'sep'}, + { + 'title': "DataSync Changes", + 'url': url('datasyncchanges'), + 'perm': 'datasync.list', + }, + { + 'title': "Tables", + 'url': url('tables'), + 'perm': 'tables.list', + }, + { + 'title': "Rattail Demo Upgrades", + 'url': url('upgrades'), + 'perm': 'upgrades.list', + }, + ], + } + menus = [ - { - 'title': "People", - 'type': 'menu', - 'items': [ - { - 'title': "Members", - 'url': url('members'), - 'perm': 'members.list', - }, - { - 'title': "Customers", - 'url': url('customers'), - 'perm': 'customers.list', - }, - { - 'title': "Employees", - 'url': url('employees'), - 'perm': 'employees.list', - }, - { - 'title': "All People", - 'url': url('people'), - 'perm': 'people.list', - }, - ], - }, - { - 'title': "Products", - 'type': 'menu', - 'items': [ - { - 'title': "Products", - 'url': url('products'), - 'perm': 'products.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': "Units of Measure", - 'url': url('uoms'), - 'perm': 'uoms.list', - }, - ], - }, - { - 'title': "Vendors", - 'type': 'menu', - 'items': [ - { - 'title': "Vendors", - 'url': url('vendors'), - 'perm': 'vendors.list', - }, - {'type': 'sep'}, - { - 'title': "Ordering", - 'url': url('ordering'), - 'perm': 'ordering.list', - }, - { - 'title': "Receiving", - 'url': url('receiving'), - 'perm': 'receiving.list', - }, - {'type': 'sep'}, - { - 'title': "Purchases", - 'url': url('purchases'), - 'perm': 'purchases.list', - }, - { - 'title': "Credits", - 'url': url('purchases.credits'), - 'perm': 'purchases.credits.list', - }, - ], - }, + people_menu, + products_menu, + vendors_menu, corepos_menu, - { - 'title': "Shopfoo", - 'type': 'menu', - 'items': [ - { - 'title': "Products", - 'url': url('shopfoo.products'), - 'perm': 'shopfoo.products.list', - }, - { - 'title': "Product Exports", - 'url': url('shopfoo.product_exports'), - 'perm': 'shopfoo.product_exports.list', - }, - {'type': 'sep'}, - { - 'title': "WooCommerce Products", - 'url': url('woocommerce.products'), - 'perm': 'woocommerce.products.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': "Appliances", - 'url': url('tempmon.appliances'), - 'perm': 'tempmon.appliances.list', - }, - { - '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': "Other", - 'type': 'menu', - 'items': [ - { - 'title': "Documentation", - 'url': 'https://rattailproject.org/moin/RattailDemo', - 'target': '_blank', - }, - { - 'title': "Source Code", - 'url': 'https://kallithea.rattailproject.org/rattail-project/rattail-demo', - 'target': '_blank', - }, - { - 'title': "RattailProject.org", - 'url': 'https://rattailproject.org', - 'target': '_blank', - }, - {'type': 'sep'}, - { - 'title': "Generate New Project", - 'url': url('generate_project'), - 'perm': 'common.generate_project', - }, - ], - }, - { - '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', - }, - {'type': 'sep'}, - { - 'title': "App Settings", - 'url': url('appsettings'), - 'perm': 'settings.list', - }, - { - 'title': "Email Settings", - 'url': url('emailprofiles'), - 'perm': 'emailprofiles.list', - }, - { - 'title': "Email Attempts", - 'url': url('email_attempts'), - 'perm': 'email_attempts.list', - }, - { - 'title': "Raw Settings", - 'url': url('settings'), - 'perm': 'settings.list', - }, - {'type': 'sep'}, - { - 'title': "DataSync Changes", - 'url': url('datasyncchanges'), - 'perm': 'datasync.list', - }, - { - 'title': "Tables", - 'url': url('tables'), - 'perm': 'tables.list', - }, - { - 'title': "Rattail Demo Upgrades", - 'url': url('upgrades'), - 'perm': 'upgrades.list', - }, - ], - }, + shopfoo_menu, + batch_menu, ] + if rattail_config.trainwreck_engine: + menus.append(trainwreck_menu) + + menus.extend([ + tempmon_menu, + other_menu, + admin_menu, + ]) + return menus diff --git a/rattail_demo/web/views/__init__.py b/rattail_demo/web/views/__init__.py index af966b1..1bd101a 100644 --- a/rattail_demo/web/views/__init__.py +++ b/rattail_demo/web/views/__init__.py @@ -54,5 +54,8 @@ def includeme(config): config.include('tailbone.views.batch.inventory') config.include('tailbone.views.batch.importer') + # trainwreck + config.include('tailbone.views.trainwreck.defaults') + # generate new project config.include('tailbone.views.projects')