Initial commit, basic menus in place

This commit is contained in:
Lance Edgar 2020-06-29 13:44:12 -05:00
commit a18852f204
15 changed files with 606 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
tailbone_theo.egg-info/

7
MANIFEST.in Normal file
View file

@ -0,0 +1,7 @@
include *.rst
recursive-include theo/web/static *.css
recursive-include theo/web/static *.js
recursive-include theo/web/templates *.mako

12
README.rst Normal file
View file

@ -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/

107
setup.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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',
],
},
)

27
theo/__init__.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
Theo package root
"""
from ._version import __version__

3
theo/_version.py Normal file
View file

@ -0,0 +1,3 @@
# -*- coding: utf-8; -*-
__version__ = '0.1.0'

42
theo/config.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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')

0
theo/web/__init__.py Normal file
View file

54
theo/web/app.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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()

175
theo/web/menus.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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

View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
Static assets
"""
def includeme(config):
config.include('tailbone.static')
config.add_static_view('tailbone_theo', 'tailbone_theo.web:static', cache_max_age=3600)

37
theo/web/subscribers.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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')

View file

@ -0,0 +1,17 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/base_meta.mako" />
<%def name="favicon()">
## <link rel="icon" type="image/x-icon" href="${request.static_url('tailbone_theo.web:static/favicon.ico')}" />
<link rel="icon" type="image/x-icon" href="${request.static_url('tailbone:static/img/rattail.ico')}" />
</%def>
<%def name="header_logo()">
${h.image(request.static_url('tailbone:static/img/rattail.ico'), "Header Logo", style="height: 49px;")}
</%def>
<%def name="footer()">
<p class="has-text-centered">
${h.link_to("Theo {}{}".format(theo.__version__, '' if request.rattail_config.production() else '+dev'), url('about'))}
</p>
</%def>

View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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')

39
theo/web/views/common.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
#
################################################################################
"""
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)