Add support for new-style rattail-demo install command

also use upstream menus where possible
This commit is contained in:
Lance Edgar 2023-01-18 14:59:26 -06:00
parent 316bdfe1aa
commit 400133a98d
5 changed files with 25 additions and 285 deletions

View file

@ -44,3 +44,18 @@ class ImportSelf(commands.ImportSubcommand):
name = 'import-self'
description = __doc__.strip()
handler_spec = 'rattail_demo.importing.local:FromRattailDemoToSelf'
class Install(commands.InstallSubcommand):
"""
Install the Rattail Demo app
"""
name = 'install'
description = __doc__.strip()
# nb. these must be explicitly set b/c config is not available
# when running normally, e.g. `rattail-demo -n install`
app_title = "Rattail Demo"
app_package = 'rattail_demo'
app_eggname = 'rattail_demo'
app_pypiname = 'rattail-demo'

View file

@ -19,7 +19,6 @@ 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', 'handler', 'rattail_demo.web.menus:DemoMenuHandler')
# default app handlers

View file

@ -1,23 +0,0 @@
# -*- coding: utf-8; -*-
"""
Email definitions
"""
# bring in some common config from rattail
from rattail.emails import (upgrade_failure,
upgrade_success,
user_feedback)
# bring in some common config from rattail_tempmon
from rattail_tempmon.emails import (tempmon_critical_high_temp,
tempmon_high_temp,
tempmon_good_temp,
tempmon_low_temp,
tempmon_critical_low_temp,
tempmon_error,
tempmon_client_offline)
# common config from rattail-corepos
from rattail_corepos.emails import (rattail_import_corepos_api_updates,
rattail_import_corepos_db_updates)

View file

@ -14,108 +14,11 @@ class DemoMenuHandler(base.MenuHandler):
def make_menus(self, request, **kwargs):
people_menu = {
'title': "People",
'type': 'menu',
'items': [
{
'title': "Members",
'route': 'members',
'perm': 'members.list',
},
{
'title': "Customers",
'route': 'customers',
'perm': 'customers.list',
},
{
'title': "Employees",
'route': 'employees',
'perm': 'employees.list',
},
{
'title': "All People",
'route': 'people',
'perm': 'people.list',
},
],
}
people_menu = self.make_people_menu(request)
products_menu = {
'title': "Products",
'type': 'menu',
'items': [
{
'title': "Products",
'route': 'products',
'perm': 'products.list',
},
{
'title': "Departments",
'route': 'departments',
'perm': 'departments.list',
},
{
'title': "Subdepartments",
'route': 'subdepartments',
'perm': 'subdepartments.list',
},
{
'title': "Brands",
'route': 'brands',
'perm': 'brands.list',
},
{
'title': "Families",
'route': 'families',
'perm': 'families.list',
},
{
'title': "Report Codes",
'route': 'reportcodes',
'perm': 'reportcodes.list',
},
{
'title': "Units of Measure",
'route': 'uoms',
'perm': 'uoms.list',
},
],
}
products_menu = self.make_products_menu(request)
vendors_menu = {
'title': "Vendors",
'type': 'menu',
'items': [
{
'title': "Vendors",
'route': 'vendors',
'perm': 'vendors.list',
},
{'type': 'sep'},
{
'title': "Ordering",
'route': 'ordering',
'perm': 'ordering.list',
},
{
'title': "Receiving",
'route': 'receiving',
'perm': 'receiving.list',
},
{'type': 'sep'},
{
'title': "Purchases",
'route': 'purchases',
'perm': 'purchases.list',
},
{
'title': "Credits",
'route': 'purchases.credits',
'perm': 'purchases.credits.list',
},
],
}
vendors_menu = self.make_vendors_menu(request)
corepos_menu = make_corepos_menu(request)
@ -142,88 +45,11 @@ class DemoMenuHandler(base.MenuHandler):
],
}
reporting_menu = {
'title': "Reporting",
'type': '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',
},
],
}
reports_menu = self.make_reports_menu(request, include_trainwreck=True)
batch_menu = {
'title': "Batches",
'type': 'menu',
'items': [
{
'title': "Handheld",
'route': 'batch.handheld',
'perm': 'batch.handheld.list',
},
{
'title': "Inventory",
'route': 'batch.inventory',
'perm': 'batch.inventory.list',
},
{
'title': "Import / Export",
'route': 'batch.importer',
'perm': 'batch.importer.list',
},
],
}
batch_menu = self.make_batches_menu(request)
trainwreck_menu = {
'title': "Trainwreck",
'type': 'menu',
'items': [
{
'title': "Transactions",
'route': 'trainwreck.transactions',
'perm': 'trainwreck.transactions.list',
},
],
}
tempmon_menu = {
'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',
},
],
}
tempmon_menu = self.make_tempmon_menu(request)
other_menu = {
'title': "Other",
@ -253,79 +79,7 @@ class DemoMenuHandler(base.MenuHandler):
],
}
admin_menu = {
'title': "Admin",
'type': 'menu',
'items': [
{
'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': "Luigi Tasks",
'route': 'luigi',
'perm': 'luigi.list',
},
{
'title': "Tables",
'route': 'tables',
'perm': 'tables.list',
},
{
'title': "Upgrades",
'route': 'upgrades',
'perm': 'upgrades.list',
},
],
}
admin_menu = self.make_admin_menu(request, include_stores=True)
menus = [
people_menu,
@ -333,17 +87,11 @@ class DemoMenuHandler(base.MenuHandler):
vendors_menu,
corepos_menu,
shopfoo_menu,
reporting_menu,
reports_menu,
batch_menu,
]
if self.config.trainwreck_engine:
menus.append(trainwreck_menu)
menus.extend([
tempmon_menu,
other_menu,
admin_menu,
])
]
return menus

View file

@ -97,6 +97,7 @@ setup(
'rattail_demo.commands': [
'export-shopfoo = rattail_demo.commands:ExportShopfoo',
'import-self = rattail_demo.commands:ImportSelf',
'install = rattail_demo.commands:Install',
],
},
)