Add some basic support for Catapult integration

can view their data directly in web app, and import to rattail tables
This commit is contained in:
Lance Edgar 2020-06-29 17:20:32 -05:00
parent a18852f204
commit 0a4ae38f88
5 changed files with 211 additions and 119 deletions

View file

@ -62,12 +62,29 @@ requires = [
#
# package # low high
# TODO: must cap this for now, b/c it breaks Catapult integration?!
# (something about "Syntax error near 'ROWS'" with grid queries)
'SQLAlchemy<1.3', # 1.2.19
'psycopg2', # 2.8.5
'rattail', # 0.9.130
'Tailbone', # 0.8.97
]
extras = {
'catapult': [
#
# package # low high
'onager', # 0.2.8
'rattail-onager', # 0.2.1
'tailbone-onager', # 0.2.3
],
}
setup(
name = "tailbone-theo",
version = __version__,
@ -91,6 +108,7 @@ setup(
],
install_requires = requires,
extras_require = extras,
packages = find_packages(),
include_package_data = True,

View file

@ -40,3 +40,7 @@ class TheoConfig(ConfigExtension):
# Theo comes with its own menu for web app
config.setdefault('tailbone', 'menus', 'theo.web.menus')
def integrate_catapult(config):
return config.getbool('theo', 'integrate_catapult', default=False)

View file

@ -26,6 +26,8 @@ Theo web app
from tailbone import app
from theo.config import integrate_catapult
def main(global_config, **settings):
"""
@ -42,6 +44,11 @@ def main(global_config, **settings):
rattail_config = app.make_rattail_config(settings)
pyramid_config = app.make_pyramid_config(settings)
# maybe add catapult integrations
if integrate_catapult(rattail_config):
from tailbone_onager.db import CatapultSession
CatapultSession.configure(bind=rattail_config.catapult_engine)
# bring in the rest of Theo
pyramid_config.include('theo.web.static')
pyramid_config.include('theo.web.subscribers')

View file

@ -24,152 +24,208 @@
Web Menus
"""
from theo.config import integrate_catapult
def simple_menus(request):
url = request.route_url
rattail_config = request.rattail_config
menus = [
{
'title': "Orders",
'type': 'menu',
'items': [
# {
# 'title': "New Order",
# 'url': url('custorders.new'),
# 'perm': 'custorders.create',
# },
include_catapult = integrate_catapult(rattail_config)
orders_menu = {
'title': "Orders",
'type': 'menu',
'items': [
# {
# 'title': "New Order",
# 'url': url('custorders.new'),
# 'perm': 'custorders.create',
# },
{
'title': "All Orders",
'url': url('custorders'),
'perm': 'custorders.list',
},
{
'title': "All Items",
'url': url('custorders.items'),
'perm': 'custorders.items.list',
},
# {
# 'title': "Configuration",
# 'url': url('custorders.config'),
# 'perm': 'custorders.configure',
# },
{
'title': "All Items",
'url': url('custorders.items'),
'perm': 'custorders.items.list',
},
# {
# 'title': "Configuration",
# 'url': url('custorders.config'),
# 'perm': 'custorders.configure',
# },
],
},
{
'title': "People",
}
people_menu = {
'title': "People",
'type': 'menu',
'items': [
{
'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': "Vendors",
'url': url('vendors'),
'perm': 'vendors.list',
},
],
}
if include_catapult:
catapult_menu = {
'title': "Catapult",
'type': 'menu',
'items': [
{
'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',
'url': url('catapult.departments'),
'perm': 'catapult.departments.list',
},
{
'title': "Subdepartments",
'url': url('subdepartments'),
'perm': 'subdepartments.list',
'title': "Terminals",
'url': url('catapult.terminals'),
'perm': 'catapult.terminals.list',
},
{
'title': "Brands",
'url': url('brands'),
'perm': 'brands.list',
'title': "Transactions",
'url': url('catapult.transactions'),
'perm': 'catapult.transactions.list',
},
{
'title': "Vendors",
'url': url('vendors'),
'perm': 'vendors.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': "Worksheets",
'url': url('catapult.worksheets'),
'perm': 'catapult.worksheets.list',
},
{'type': 'sep'},
{
'title': "App Settings",
'url': url('appsettings'),
'perm': 'settings.list',
'title': "Security Profiles",
'url': url('catapult.security_profiles'),
'perm': 'catapult.security_profiles.view',
},
{
'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': "Theo Upgrades",
'url': url('upgrades'),
'perm': 'upgrades.list',
'title': "Master Functions",
'url': url('catapult.master_functions'),
'perm': 'catapult.master_functions.view',
},
],
},
}
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': "Theo Upgrades",
'url': url('upgrades'),
'perm': 'upgrades.list',
},
],
}
menus = [
orders_menu,
people_menu,
products_menu,
]
if include_catapult:
menus.append(catapult_menu)
menus.append(admin_menu)
return menus

View file

@ -24,8 +24,11 @@
Views
"""
from theo.config import integrate_catapult
def includeme(config):
rattail_config = config.registry.settings.get('rattail_config')
# core views
config.include('theo.web.views.common')
@ -53,3 +56,7 @@ def includeme(config):
config.include('tailbone.views.subdepartments')
config.include('tailbone.views.users')
config.include('tailbone.views.vendors')
# catapult views
if integrate_catapult(rattail_config):
config.include('tailbone_onager.views')