diff --git a/setup.py b/setup.py index 29208dc..5494b7e 100644 --- a/setup.py +++ b/setup.py @@ -82,6 +82,19 @@ extras = { 'rattail-onager', # 0.2.1 'tailbone-onager', # 0.2.3 ], + + 'corepos': [ + # + # package # low high + + # TODO: must cap this for now, b/c it breaks CORE-POS integration?! + # (sometimes there are segfaults with basic grid queries) + 'mysql-connector-python==8.0.17', + + 'pyCOREPOS', # 0.1.0 + 'rattail-corepos', # 0.1.0 + 'tailbone-corepos', # 0.1.1 + ], } diff --git a/theo/config.py b/theo/config.py index 1420070..00668d5 100644 --- a/theo/config.py +++ b/theo/config.py @@ -38,9 +38,19 @@ class TheoConfig(ConfigExtension): # call the app "Theo" by default config.setdefault('rattail', 'app_title', "Theo") + # Theo may define a custom data model + if integrate_corepos(config): + config.setdefault('rattail', 'model', 'theo.db.model_corepos') + # 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) + return config.getbool('theo', 'integrate_catapult', default=False, + usedb=False) + + +def integrate_corepos(config): + return config.getbool('theo', 'integrate_corepos', default=False, + usedb=False) diff --git a/theo/db/__init__.py b/theo/db/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/theo/db/model_corepos.py b/theo/db/model_corepos.py new file mode 100644 index 0000000..44a5417 --- /dev/null +++ b/theo/db/model_corepos.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8; -*- +################################################################################ +# +# Rattail -- Retail Software Framework +# Copyright © 2010-2020 Lance Edgar +# +# This file is part of Rattail. +# +# Rattail is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# Rattail. If not, see . +# +################################################################################ +""" +Theo data model w/ CORE-POS integration +""" + +# bring in all the normal stuff from Rattail +from rattail.db.model import * + +# also bring in CORE integration models +from rattail_corepos.db.model import * diff --git a/theo/web/app.py b/theo/web/app.py index 6187e11..f1f73fb 100644 --- a/theo/web/app.py +++ b/theo/web/app.py @@ -26,7 +26,7 @@ Theo web app from tailbone import app -from theo.config import integrate_catapult +from theo.config import integrate_catapult, integrate_corepos def main(global_config, **settings): @@ -44,10 +44,13 @@ def main(global_config, **settings): rattail_config = app.make_rattail_config(settings) pyramid_config = app.make_pyramid_config(settings) - # maybe add catapult integrations + # maybe configure integration db connections if integrate_catapult(rattail_config): from tailbone_onager.db import CatapultSession CatapultSession.configure(bind=rattail_config.catapult_engine) + if integrate_corepos(rattail_config): + from tailbone_corepos.db import CoreOfficeSession + CoreOfficeSession.configure(bind=rattail_config.corepos_engine) # bring in the rest of Theo pyramid_config.include('theo.web.static') diff --git a/theo/web/menus.py b/theo/web/menus.py index 5ade59a..480aec2 100644 --- a/theo/web/menus.py +++ b/theo/web/menus.py @@ -24,7 +24,7 @@ Web Menus """ -from theo.config import integrate_catapult +from theo.config import integrate_catapult, integrate_corepos def simple_menus(request): @@ -32,6 +32,7 @@ def simple_menus(request): rattail_config = request.rattail_config include_catapult = integrate_catapult(rattail_config) + include_corepos = integrate_corepos(rattail_config) orders_menu = { 'title': "Orders", @@ -153,6 +154,59 @@ def simple_menus(request): ], } + if include_corepos: + corepos_menu = { + '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': "Member Types", + 'url': url('corepos.member_types'), + 'perm': 'corepos.member_types.list', + }, + { + 'title': "Members", + 'url': url('corepos.members'), + 'perm': 'corepos.members.list', + }, + { + 'title': "Employees", + 'url': url('corepos.employees'), + 'perm': 'corepos.employees.list', + }, + # { + # 'title': "Transaction Details", + # 'url': url('corepos.transaction_details'), + # 'perm': 'corepos.transaction_details.list', + # }, + ], + } + admin_menu = { 'title': "Admin", 'type': 'menu', @@ -225,6 +279,8 @@ def simple_menus(request): if include_catapult: menus.append(catapult_menu) + if include_corepos: + menus.append(corepos_menu) menus.append(admin_menu) diff --git a/theo/web/views/__init__.py b/theo/web/views/__init__.py index bd8a4fc..9d87911 100644 --- a/theo/web/views/__init__.py +++ b/theo/web/views/__init__.py @@ -24,7 +24,7 @@ Views """ -from theo.config import integrate_catapult +from theo.config import integrate_catapult, integrate_corepos def includeme(config): @@ -60,3 +60,7 @@ def includeme(config): # catapult views if integrate_catapult(rattail_config): config.include('tailbone_onager.views') + + # corepos views + if integrate_corepos(rattail_config): + config.include('tailbone_corepos.views')