From 23dea7bcedb3144263109067b6d45a2a0d26110d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 18 Jan 2023 16:55:30 -0600 Subject: [PATCH] Add more views, menus to default set --- tailbone/menus.py | 311 +++++++++++++++++++++++++---------- tailbone/views/essentials.py | 7 +- 2 files changed, 231 insertions(+), 87 deletions(-) diff --git a/tailbone/menus.py b/tailbone/menus.py index e956685d..c42f91ae 100644 --- a/tailbone/menus.py +++ b/tailbone/menus.py @@ -259,6 +259,7 @@ class MenuHandler(GenericHandler): is expected for most apps to override it. """ menus = [ + self.make_custorders_menu(request), self.make_people_menu(request), self.make_products_menu(request), self.make_vendors_menu(request), @@ -269,9 +270,9 @@ class MenuHandler(GenericHandler): menus.extend(integration_menus) menus.extend([ - # TODO: add reporting menu + self.make_reports_menu(request, include_trainwreck=True), self.make_batches_menu(request), - self.make_admin_menu(request), + self.make_admin_menu(request, include_stores=True), ]) return menus @@ -288,6 +289,38 @@ class MenuHandler(GenericHandler): menus.sort(key=lambda menu: menu['title'].lower()) return menus + def make_custorders_menu(self, request, **kwargs): + """ + Generate a typical Customer Orders menu + """ + return { + 'title': "Orders", + 'type': 'menu', + 'items': [ + { + 'title': "New Customer Order", + 'route': 'custorders.create', + 'perm': 'custorders.create', + }, + { + 'title': "All New Orders", + 'route': 'new_custorders', + 'perm': 'new_custorders.list', + }, + {'type': 'sep'}, + { + 'title': "All Customer Orders", + 'route': 'custorders', + 'perm': 'custorders.list', + }, + { + 'title': "All Order Items", + 'route': 'custorders.items', + 'perm': 'custorders.items.list', + }, + ], + } + def make_people_menu(self, request, **kwargs): """ Generate a typical People menu @@ -321,6 +354,12 @@ class MenuHandler(GenericHandler): 'route': 'people', 'perm': 'people.list', }, + {'type': 'sep'}, + { + 'title': "Pending Customers", + 'route': 'pending_customers', + 'perm': 'pending_customers.list', + }, ], } @@ -362,6 +401,17 @@ class MenuHandler(GenericHandler): 'route': 'reportcodes', 'perm': 'reportcodes.list', }, + { + 'title': "Units of Measure", + 'route': 'uoms', + 'perm': 'uoms.list', + }, + {'type': 'sep'}, + { + 'title': "Pending Products", + 'route': 'pending_products', + 'perm': 'pending_products.list', + }, ], } @@ -400,13 +450,13 @@ class MenuHandler(GenericHandler): 'route': 'purchases.credits', 'perm': 'purchases.credits.list', }, - # {'type': 'sep'}, - # { - # 'title': "Catalogs", - # 'route': 'vendorcatalogs', - # 'perm': 'vendorcatalogs.list', - # }, - ], + {'type': 'sep'}, + { + 'title': "Catalog Batches", + 'route': 'vendorcatalogs', + 'perm': 'vendorcatalogs.list', + }, + ], } def make_batches_menu(self, request, **kwargs): @@ -422,95 +472,184 @@ class MenuHandler(GenericHandler): 'route': 'batch.handheld', 'perm': 'batch.handheld.list', }, - # { - # 'title': "Inventory", - # 'route': 'batch.inventory', - # 'perm': 'batch.inventory.list', - # }, - ], + { + 'title': "Inventory", + 'route': 'batch.inventory', + 'perm': 'batch.inventory.list', + }, + { + 'title': "Import / Export", + 'route': 'batch.importer', + 'perm': 'batch.importer.list', + }, + ], + } + + def make_reports_menu(self, request, **kwargs): + """ + Generate a typical Reports menu + """ + items = [ + { + 'title': "New Report", + 'route': 'report_output.create', + 'perm': 'report_output.create', + }, + { + 'title': "Generated Reports", + 'route': 'report_output', + 'perm': 'report_output.list', + }, + { + 'title': "Problem Reports", + 'route': 'problem_reports', + 'perm': 'problem_reports.list', + }, + ] + + if kwargs.get('include_poser', False): + items.extend([ + {'type': 'sep'}, + { + 'title': "Poser Reports", + 'route': 'poser_reports', + 'perm': 'poser_reports.list', + }, + ]) + + if kwargs.get('include_trainwreck', False): + items.extend([ + {'type': 'sep'}, + { + 'title': "Trainwreck", + 'route': 'trainwreck.transactions', + 'perm': 'trainwreck.transactions.list', + }, + ]) + + return { + 'title': "Reports", + 'type': 'menu', + 'items': items, + } + + def make_tempmon_menu(self, request, **kwargs): + """ + Generate a typical TempMon menu + """ + return { + 'title': "TempMon", + 'type': 'menu', + 'items': [ + { + 'title': "Appliances", + 'route': 'tempmon.appliances', + 'perm': 'tempmon.appliances.list', + }, + { + 'title': "Clients", + 'route': 'tempmon.clients', + 'perm': 'tempmon.clients.list', + }, + { + 'title': "Probes", + 'route': 'tempmon.probes', + 'perm': 'tempmon.probes.list', + }, + { + 'title': "Readings", + 'route': 'tempmon.readings', + 'perm': 'tempmon.readings.list', + }, + ], } def make_admin_menu(self, request, **kwargs): """ Generate a typical Admin menu """ - return { - 'title': "Admin", - 'type': 'menu', - 'items': [ + items = [] + + if kwargs.get('include_stores', True): + items.extend([ { 'title': "Stores", 'route': 'stores', 'perm': 'stores.list', }, - { - 'title': "Users", - 'route': 'users', - 'perm': 'users.list', - }, - { - 'title': "User Events", - 'route': 'userevents', - 'perm': 'userevents.list', - }, - { - 'title': "Roles", - 'route': 'roles', - 'perm': 'roles.list', - }, {'type': 'sep'}, - { - 'title': "App Settings", - 'route': 'appsettings', - 'perm': 'settings.list', - }, - { - 'title': "Email Settings", - 'route': 'emailprofiles', - 'perm': 'emailprofiles.list', - }, - { - 'title': "Email Attempts", - 'route': 'email_attempts', - 'perm': 'email_attempts.list', - }, - { - 'title': "Raw Settings", - 'route': 'settings', - 'perm': 'settings.list', - }, - {'type': 'sep'}, - { - 'title': "DataSync Changes", - 'route': 'datasyncchanges', - 'perm': 'datasync_changes.list', - }, - { - 'title': "DataSync Status", - 'route': 'datasync.status', - 'perm': 'datasync.status', - }, - { - 'title': "Importing / Exporting", - 'route': 'importing', - 'perm': 'importing.list', - }, - { - 'title': "Luigi Tasks", - 'route': 'luigi', - 'perm': 'luigi.list', - }, - { - 'title': "App Details", - 'route': 'appinfo', - 'perm': 'appinfo.list', - }, - { - 'title': "Upgrades", - 'route': 'upgrades', - 'perm': 'upgrades.list', - }, - ], + ]) + + items.extend([ + { + 'title': "Users", + 'route': 'users', + 'perm': 'users.list', + }, + { + 'title': "Roles", + 'route': 'roles', + 'perm': 'roles.list', + }, + { + 'title': "Raw Permissions", + 'route': 'permissions', + 'perm': 'permissions.list', + }, + {'type': 'sep'}, + { + 'title': "Email Settings", + 'route': 'emailprofiles', + 'perm': 'emailprofiles.list', + }, + { + 'title': "Email Attempts", + 'route': 'email_attempts', + 'perm': 'email_attempts.list', + }, + {'type': 'sep'}, + { + 'title': "DataSync Status", + 'route': 'datasync.status', + 'perm': 'datasync.status', + }, + { + 'title': "DataSync Changes", + 'route': 'datasyncchanges', + 'perm': 'datasync_changes.list', + }, + { + 'title': "Importing / Exporting", + 'route': 'importing', + 'perm': 'importing.list', + }, + { + 'title': "Luigi Tasks", + 'route': 'luigi', + 'perm': 'luigi.list', + }, + {'type': 'sep'}, + { + 'title': "App Details", + 'route': 'appinfo', + 'perm': 'appinfo.list', + }, + { + 'title': "Raw Settings", + 'route': 'settings', + 'perm': 'settings.list', + }, + { + 'title': "Upgrades", + 'route': 'upgrades', + 'perm': 'upgrades.list', + }, + ]) + + return { + 'title': "Admin", + 'type': 'menu', + 'items': items, } diff --git a/tailbone/views/essentials.py b/tailbone/views/essentials.py index b38749d1..c59eb794 100644 --- a/tailbone/views/essentials.py +++ b/tailbone/views/essentials.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -30,12 +30,17 @@ from __future__ import unicode_literals, absolute_import def includeme(config): config.include('tailbone.views.auth') config.include('tailbone.views.common') + config.include('tailbone.views.datasync') config.include('tailbone.views.email') + config.include('tailbone.views.importing') + config.include('tailbone.views.luigi') config.include('tailbone.views.menus') config.include('tailbone.views.people') config.include('tailbone.views.progress') + config.include('tailbone.views.reports') config.include('tailbone.views.roles') config.include('tailbone.views.settings') config.include('tailbone.views.tables') config.include('tailbone.views.upgrades') config.include('tailbone.views.users') + config.include('tailbone.views.views')