commit a18852f204b7e510ebc09fe4990b3e645eb9b658 Author: Lance Edgar Date: Mon Jun 29 13:44:12 2020 -0500 Initial commit, basic menus in place diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31e37f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tailbone_theo.egg-info/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e597c4c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,7 @@ + +include *.rst + +recursive-include theo/web/static *.css +recursive-include theo/web/static *.js + +recursive-include theo/web/templates *.mako diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..ec2de71 --- /dev/null +++ b/README.rst @@ -0,0 +1,12 @@ + +tailbone-theo +============= + +This is an experimental project, as of this writing. Its purpose is 2-fold: + +* hopefully provide a useful app for managing special/case orders for customers +* either way, hopefully provide a good working example of the code + +See the `Rattail website`_ for more info. + +.. _`Rattail website`: https://rattailproject.org/ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..deabfae --- /dev/null +++ b/setup.py @@ -0,0 +1,107 @@ +# -*- 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 setup script +""" + +import os +from setuptools import setup, find_packages + + +here = os.path.abspath(os.path.dirname(__file__)) +exec(open(os.path.join(here, 'theo', '_version.py')).read()) +README = open(os.path.join(here, 'README.rst')).read() + + +requires = [ + # + # Version numbers within comments below have specific meanings. + # Basically the 'low' value is a "soft low," and 'high' a "soft high." + # In other words: + # + # If either a 'low' or 'high' value exists, the primary point to be + # made about the value is that it represents the most current (stable) + # version available for the package (assuming typical public access + # methods) whenever this project was started and/or documented. + # Therefore: + # + # If a 'low' version is present, you should know that attempts to use + # versions of the package significantly older than the 'low' version + # may not yield happy results. (A "hard" high limit may or may not be + # indicated by a true version requirement.) + # + # Similarly, if a 'high' version is present, and especially if this + # project has laid dormant for a while, you may need to refactor a bit + # when attempting to support a more recent version of the package. (A + # "hard" low limit should be indicated by a true version requirement + # when a 'high' version is present.) + # + # In any case, developers and other users are encouraged to play + # outside the lines with regard to these soft limits. If bugs are + # encountered then they should be filed as such. + # + # package # low high + + 'psycopg2', # 2.8.5 + 'rattail', # 0.9.130 + 'Tailbone', # 0.8.97 +] + + +setup( + name = "tailbone-theo", + version = __version__, + author = "Lance Edgar", + author_email = "lance@edbob.org", + url = "https://rattailproject.org", + description = "Theo, the order system", + long_description = README, + + classifiers = [ + 'Development Status :: 3 - Alpha', + 'Environment :: Console', + 'Environment :: Web Environment', + 'Framework :: Pyramid', + 'Intended Audience :: Developers', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Office/Business', + ], + + install_requires = requires, + packages = find_packages(), + include_package_data = True, + + entry_points = { + + 'rattail.config.extensions': [ + 'theo = theo.config:TheoConfig', + ], + + 'paste.app_factory': [ + 'main = theo.web.app:main', + ], + }, +) diff --git a/theo/__init__.py b/theo/__init__.py new file mode 100644 index 0000000..b05f002 --- /dev/null +++ b/theo/__init__.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 package root +""" + +from ._version import __version__ diff --git a/theo/_version.py b/theo/_version.py new file mode 100644 index 0000000..e41b669 --- /dev/null +++ b/theo/_version.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8; -*- + +__version__ = '0.1.0' diff --git a/theo/config.py b/theo/config.py new file mode 100644 index 0000000..99b231f --- /dev/null +++ b/theo/config.py @@ -0,0 +1,42 @@ +# -*- 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 . +# +################################################################################ +""" +Configuration for Theo +""" + +from rattail.config import ConfigExtension + + +class TheoConfig(ConfigExtension): + """ + Rattail config extension for Theo + """ + key = 'theo' + + def configure(self, config): + + # call the app "Theo" by default + config.setdefault('rattail', 'app_title', "Theo") + + # Theo comes with its own menu for web app + config.setdefault('tailbone', 'menus', 'theo.web.menus') diff --git a/theo/web/__init__.py b/theo/web/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/theo/web/app.py b/theo/web/app.py new file mode 100644 index 0000000..880db11 --- /dev/null +++ b/theo/web/app.py @@ -0,0 +1,54 @@ +# -*- 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 web app +""" + +from tailbone import app + + +def main(global_config, **settings): + """ + This function returns a Pyramid WSGI application. + """ + # prefer Theo templates over Tailbone + settings.setdefault('mako.directories', ['theo.web:templates', + 'tailbone:templates',]) + + # for graceful handling of postgres restart + settings.setdefault('retry.attempts', 2) + + # make config objects + rattail_config = app.make_rattail_config(settings) + pyramid_config = app.make_pyramid_config(settings) + + # bring in the rest of Theo + pyramid_config.include('theo.web.static') + pyramid_config.include('theo.web.subscribers') + pyramid_config.include('theo.web.views') + + # for graceful handling of postgres restart + pyramid_config.add_tween('tailbone.tweens.sqlerror_tween_factory', + under='pyramid_tm.tm_tween_factory') + + return pyramid_config.make_wsgi_app() diff --git a/theo/web/menus.py b/theo/web/menus.py new file mode 100644 index 0000000..d587f27 --- /dev/null +++ b/theo/web/menus.py @@ -0,0 +1,175 @@ +# -*- 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 . +# +################################################################################ +""" +Web Menus +""" + + +def simple_menus(request): + url = request.route_url + + menus = [ + { + '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': "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', + }, + ], + }, + { + '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', + }, + ], + }, + { + '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', + }, + ], + }, + ] + + return menus diff --git a/theo/web/static/__init__.py b/theo/web/static/__init__.py new file mode 100644 index 0000000..27d3458 --- /dev/null +++ b/theo/web/static/__init__.py @@ -0,0 +1,30 @@ +# -*- 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 . +# +################################################################################ +""" +Static assets +""" + + +def includeme(config): + config.include('tailbone.static') + config.add_static_view('tailbone_theo', 'tailbone_theo.web:static', cache_max_age=3600) diff --git a/theo/web/subscribers.py b/theo/web/subscribers.py new file mode 100644 index 0000000..ab52701 --- /dev/null +++ b/theo/web/subscribers.py @@ -0,0 +1,37 @@ +# -*- 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 . +# +################################################################################ +""" +Pyramid event subscribers +""" + +import theo + + +def add_theo_to_context(event): + renderer_globals = event + renderer_globals['theo'] = theo + + +def includeme(config): + config.include('tailbone.subscribers') + config.add_subscriber(add_theo_to_context, 'pyramid.events.BeforeRender') diff --git a/theo/web/templates/base_meta.mako b/theo/web/templates/base_meta.mako new file mode 100644 index 0000000..8a1b17d --- /dev/null +++ b/theo/web/templates/base_meta.mako @@ -0,0 +1,17 @@ +## -*- coding: utf-8; mode: html; -*- +<%inherit file="tailbone:templates/base_meta.mako" /> + +<%def name="favicon()"> + ## + + + +<%def name="header_logo()"> + ${h.image(request.static_url('tailbone:static/img/rattail.ico'), "Header Logo", style="height: 49px;")} + + +<%def name="footer()"> +

+ ${h.link_to("Theo {}{}".format(theo.__version__, '' if request.rattail_config.production() else '+dev'), url('about'))} +

+ diff --git a/theo/web/views/__init__.py b/theo/web/views/__init__.py new file mode 100644 index 0000000..a711c0c --- /dev/null +++ b/theo/web/views/__init__.py @@ -0,0 +1,55 @@ +# -*- 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 . +# +################################################################################ +""" +Views +""" + + +def includeme(config): + + # core views + config.include('theo.web.views.common') + config.include('tailbone.views.auth') + config.include('tailbone.views.tables') + config.include('tailbone.views.upgrades') + config.include('tailbone.views.progress') + + # main table views + config.include('tailbone.views.brands') + config.include('tailbone.views.customers') + config.include('tailbone.views.customergroups') + config.include('tailbone.views.custorders') + config.include('tailbone.views.datasync') + config.include('tailbone.views.departments') + config.include('tailbone.views.email') + config.include('tailbone.views.employees') + config.include('tailbone.views.messages') + config.include('tailbone.views.people') + config.include('tailbone.views.products') + config.include('tailbone.views.reportcodes') + config.include('tailbone.views.roles') + config.include('tailbone.views.settings') + config.include('tailbone.views.stores') + config.include('tailbone.views.subdepartments') + config.include('tailbone.views.users') + config.include('tailbone.views.vendors') diff --git a/theo/web/views/common.py b/theo/web/views/common.py new file mode 100644 index 0000000..7f0c812 --- /dev/null +++ b/theo/web/views/common.py @@ -0,0 +1,39 @@ +# -*- 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 . +# +################################################################################ +""" +Common views +""" + +from tailbone.views import common as base + +import theo + + +class CommonView(base.CommonView): + + project_title = "tailbone-theo" + project_version = theo.__version__ + '+dev' + + +def includeme(config): + CommonView.defaults(config)