From 5260270ae71f5885e24e7b81612a36615f443677 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 20 Sep 2020 22:09:44 -0500 Subject: [PATCH] Add basic support for LOC SMS integration --- setup.py | 9 +++++++ theo/config.py | 11 +++++++++ theo/db/model_locsms.py | 31 ++++++++++++++++++++++++ theo/emails/locsms.py | 27 +++++++++++++++++++++ theo/importing/versions_locsms.py | 40 +++++++++++++++++++++++++++++++ theo/web/app.py | 7 +++++- theo/web/menus.py | 9 ++++++- theo/web/views/__init__.py | 17 ++++++++++++- 8 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 theo/db/model_locsms.py create mode 100644 theo/emails/locsms.py create mode 100644 theo/importing/versions_locsms.py diff --git a/setup.py b/setup.py index 59cd5d2..9329555 100644 --- a/setup.py +++ b/setup.py @@ -109,6 +109,15 @@ extras = { 'rattail-fabric2', # 0.2.3 ], + + 'locsms': [ + # + # package # low high + + 'luckysmores', # 0.2.3 + 'rattail-luckysmores', # 0.8.2 + 'tailbone-locsms', # 0.1.0 + ], } diff --git a/theo/config.py b/theo/config.py index 8dbab7e..7cc56e8 100644 --- a/theo/config.py +++ b/theo/config.py @@ -56,6 +56,12 @@ class TheoConfig(ConfigExtension): config.setdefault('rattail.mail', 'emails', 'theo.emails.theo, theo.emails.catapult') config.setdefault('rattail.importing', 'versions.handler', 'theo.importing.versions_catapult:FromTheoToTheoVersions') + # do we integrate w/ LOC SMS? + elif integrate_locsms(config): + config.setdefault('rattail', 'model', 'theo.db.model_locsms') + config.setdefault('rattail.mail', 'emails', 'theo.emails.theo, theo.emails.locsms') + config.setdefault('rattail.importing', 'versions.handler', 'theo.importing.versions_locsms:FromTheoToTheoVersions') + else: # no integration config.setdefault('rattail.mail', 'emails', 'theo.emails.theo') @@ -68,3 +74,8 @@ def integrate_catapult(config): def integrate_corepos(config): return config.getbool('theo', 'integrate_corepos', default=False, usedb=False) + + +def integrate_locsms(config): + return config.getbool('theo', 'integrate_locsms', default=False, + usedb=False) diff --git a/theo/db/model_locsms.py b/theo/db/model_locsms.py new file mode 100644 index 0000000..d48d279 --- /dev/null +++ b/theo/db/model_locsms.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/ LOC SMS integration +""" + +# bring in all the normal stuff from Rattail +from rattail.db.model import * + +# also bring in LOC SMS integration models +from rattail_luckysmores.db.model import * diff --git a/theo/emails/locsms.py b/theo/emails/locsms.py new file mode 100644 index 0000000..6321549 --- /dev/null +++ b/theo/emails/locsms.py @@ -0,0 +1,27 @@ +# -*- 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 email profile settings +""" + +from rattail_luckysmores.emails import rattail_import_locsms_updates diff --git a/theo/importing/versions_locsms.py b/theo/importing/versions_locsms.py new file mode 100644 index 0000000..51da608 --- /dev/null +++ b/theo/importing/versions_locsms.py @@ -0,0 +1,40 @@ +# -*- 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 -> Theo "versions" data import, w/ LOC SMS integration +""" + +from rattail.importing import versions as base +from rattail_luckysmores.importing.versions import LocVersionMixin + + +class FromTheoToTheoVersions(base.FromRattailToRattailVersions, + LocVersionMixin): + """ + Handler for Theo -> Theo "versions" data import + """ + + def get_importers(self): + importers = super(FromTheoToTheoVersions, self).get_importers() + importers = self.add_locsms_importers(importers) + return importers diff --git a/theo/web/app.py b/theo/web/app.py index 564b89e..076fbdf 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, integrate_corepos +from theo.config import integrate_catapult, integrate_corepos, integrate_locsms def main(global_config, **settings): @@ -42,6 +42,8 @@ def main(global_config, **settings): directories.append('tailbone_corepos:templates') if integrate_catapult(rattail_config): directories.append('tailbone_onager:templates') + if integrate_locsms(rattail_config): + directories.append('tailbone_locsms:templates') directories.append('tailbone:templates') settings.setdefault('mako.directories', directories) @@ -58,6 +60,9 @@ def main(global_config, **settings): if integrate_corepos(rattail_config): from tailbone_corepos.db import CoreOfficeSession CoreOfficeSession.configure(bind=rattail_config.corepos_engine) + if integrate_locsms(rattail_config): + from tailbone_locsms.db import SmsSession + SmsSession.configure(bind=rattail_config.locsms_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 35071e0..a37fd6d 100644 --- a/theo/web/menus.py +++ b/theo/web/menus.py @@ -24,7 +24,7 @@ Web Menus """ -from theo.config import integrate_catapult, integrate_corepos +from theo.config import integrate_catapult, integrate_corepos, integrate_locsms def simple_menus(request): @@ -33,6 +33,7 @@ def simple_menus(request): include_catapult = integrate_catapult(rattail_config) include_corepos = integrate_corepos(rattail_config) + include_locsms = integrate_locsms(rattail_config) orders_menu = { 'title': "Orders", @@ -174,6 +175,10 @@ def simple_menus(request): from tailbone_corepos.menus import make_corepos_menu corepos_menu = make_corepos_menu(request) + if include_locsms: + from tailbone_locsms.menus import make_locsms_menu + locsms_menu = make_locsms_menu(request) + admin_menu = { 'title': "Admin", 'type': 'menu', @@ -248,6 +253,8 @@ def simple_menus(request): menus.append(catapult_menu) if include_corepos: menus.append(corepos_menu) + if include_locsms: + menus.append(locsms_menu) menus.append(admin_menu) diff --git a/theo/web/views/__init__.py b/theo/web/views/__init__.py index f567aaf..ec40156 100644 --- a/theo/web/views/__init__.py +++ b/theo/web/views/__init__.py @@ -24,7 +24,7 @@ Views """ -from theo.config import integrate_catapult, integrate_corepos +from theo.config import integrate_catapult, integrate_corepos, integrate_locsms def includeme(config): @@ -78,6 +78,21 @@ def includeme(config): config.include('tailbone_corepos.views.products') config.include('tailbone_corepos.views.corepos') + # do we integrate w/ LOC SMS? + elif integrate_locsms(rattail_config): + config.include('tailbone.views.stores') + config.include('tailbone.views.customers') + config.include('tailbone.views.members') + config.include('tailbone.views.employees') + config.include('tailbone.views.people') + config.include('tailbone.views.taxes') + config.include('tailbone.views.departments') + config.include('tailbone.views.subdepartments') + config.include('tailbone.views.brands') + config.include('tailbone.views.vendors') + config.include('tailbone.views.products') + config.include('tailbone_locsms.views.locsms') + else: # no POS integration config.include('tailbone.views.stores') config.include('tailbone.views.customers')