Initial content as generated from scaffold

This commit is contained in:
Lance Edgar 2019-08-16 20:46:01 +00:00
commit 9b0bbb74c2
27 changed files with 748 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
Rattail Tutorial.egg-info/

8
MANIFEST.in Normal file
View file

@ -0,0 +1,8 @@
# -*- mode: conf -*-
include *.rst
recursive-include rattail_tutorial/web/static *.css
recursive-include rattail_tutorial/web/static *.js
recursive-include rattail_tutorial/web/templates *.mako

8
README.rst Normal file
View file

@ -0,0 +1,8 @@
.. -*- mode: rst -*-
rattail-tutorial
===========
This is a starter Rattail project. See the `Rattail website`_ for more info.
.. _`Rattail website`: https://rattailproject.org/

View file

@ -0,0 +1,8 @@
# -*- coding: utf-8; -*-
"""
Rattail Tutorial package root
"""
from __future__ import unicode_literals, absolute_import
from ._version import __version__

View file

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

View file

@ -0,0 +1,42 @@
# -*- coding: utf-8; mode: python -*-
"""
Rattail Tutorial commands
"""
from __future__ import unicode_literals, absolute_import
import sys
from rattail import commands
from rattail_tutorial import __version__
def main(*args):
"""
Main entry point for Rattail Tutorial command system
"""
args = list(args or sys.argv[1:])
cmd = Command()
cmd.run(*args)
class Command(commands.Command):
"""
Main command for Rattail Tutorial
"""
name = 'rattail_tutorial'
version = __version__
description = "Rattail Tutorial (custom Rattail system)"
long_description = ''
class HelloWorld(commands.Subcommand):
"""
The requisite 'hello world' example
"""
name = 'hello'
description = __doc__.strip()
def run(self, args):
self.stdout.write("hello world!\n")

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8; mode: python; -*-
"""
Custom config
"""
from __future__ import unicode_literals, absolute_import
from rattail.config import ConfigExtension
class Rattail_tutorialConfig(ConfigExtension):
"""
Rattail config extension for Rattail Tutorial
"""
key = 'rattail_tutorial'
def configure(self, config):
# set some default config values
config.setdefault('rattail.mail', 'emails', 'rattail_tutorial.emails')
config.setdefault('tailbone', 'menus', 'rattail_tutorial.web.menus')

View file

View file

@ -0,0 +1 @@
Generic single-database configuration.

View file

@ -0,0 +1,76 @@
# -*- coding: utf-8; mode: python; -*-
"""
Alembic environment script
"""
from __future__ import unicode_literals, absolute_import
from alembic import context
from sqlalchemy.orm import configure_mappers
from rattail.config import make_config
from rattail.db.util import get_default_engine
from rattail.db.continuum import configure_versioning
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
alembic_config = context.config
# use same config file for Rattail
rattail_config = make_config(alembic_config.config_file_name, usedb=False, versioning=False)
# configure Continuum..this is trickier than we want but it works..
configure_versioning(rattail_config, force=True)
from rattail_tutorial.db import model
configure_mappers()
# needed for 'autogenerate' support
target_metadata = model.Base.metadata
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
engine = get_default_engine(rattail_config)
context.configure(
url=engine.url,
target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
engine = get_default_engine(rattail_config)
connection = engine.connect()
context.configure(
connection=connection,
target_metadata=target_metadata)
try:
with context.begin_transaction():
context.run_migrations()
finally:
connection.close()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8; mode: python; -*-
# -*- coding: utf-8 -*-
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from __future__ import unicode_literals, absolute_import
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
from alembic import op
import sqlalchemy as sa
import rattail.db.types
${imports if imports else ""}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

View file

@ -0,0 +1,12 @@
# -*- coding: utf-8; mode: python; -*-
"""
Rattail Tutorial data models
"""
from __future__ import unicode_literals, absolute_import
# bring in all the normal stuff from Rattail
from rattail.db.model import *
# add Rattail Tutorial models
from .core import Rattail_tutorialCustomer

View file

@ -0,0 +1,43 @@
# -*- coding: utf-8; mode: python -*-
"""
Rattail core data model extensions
"""
from __future__ import unicode_literals, absolute_import
import sqlalchemy as sa
from sqlalchemy import orm
from rattail.db import model
from rattail.db.core import uuid_column
class Rattail_tutorialCustomer(model.Base):
"""
Rattail Tutorial extensions to core Customer model
"""
__tablename__ = 'rattail_tutorial_customer'
__table_args__ = (
sa.ForeignKeyConstraint(['uuid'], ['customer.uuid'], name='rattail_tutorial_customer_fk_customer'),
)
uuid = uuid_column(default=None)
customer = orm.relationship(
model.Customer,
doc="""
Customer to which this extension record pertains.
""",
backref=orm.backref(
'_rattail_tutorial',
uselist=False,
cascade='all, delete-orphan',
doc="""
Rattail Tutorial-specific extension record for the customer.
"""),
)
mail_list_synced = sa.Column(sa.Boolean(), nullable=False, default=False, doc="""
Flag indicating whether the customer's email address has been synced to the
general mailing list.
""")

View file

@ -0,0 +1,19 @@
# -*- coding: utf-8; mode: python -*-
"""
Custom email profiles
"""
from __future__ import unicode_literals, absolute_import
from rattail.mail import Email
# bring in some common ones from rattail
from rattail.emails import datasync_error_watcher_get_changes, filemon_action_error
class rattail_import_sample_updates(Email):
"""
Sent when a Sample -> Rattail Tutorial import involves data changes
"""
fallback_key = 'rattail_import_updates'
default_subject = "Changes for Sample -> Rattail Tutorial"

View file

View file

@ -0,0 +1,35 @@
# -*- coding: utf-8; mode: python; -*-
"""
Rattail Tutorial web app
"""
from __future__ import unicode_literals, absolute_import
from tailbone import app
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# prefer Rattail Tutorial templates over Tailbone
settings.setdefault('mako.directories', ['rattail_tutorial.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 Rattail Tutorial
pyramid_config.include('rattail_tutorial.web.static')
pyramid_config.include('rattail_tutorial.web.subscribers')
pyramid_config.include('rattail_tutorial.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()

View file

@ -0,0 +1,170 @@
# -*- coding: utf-8; -*-
"""
Web Menus
"""
from __future__ import unicode_literals, absolute_import
def simple_menus(request):
url = request.route_url
menus = [
{
'title': "Products",
'type': 'menu',
'items': [
{
'title': "Products",
'url': url('products'),
'perm': 'products.list',
},
{
'title': "Brands",
'url': url('brands'),
'perm': 'brands.list',
},
{
'title': "Report Codes",
'url': url('reportcodes'),
'perm': 'reportcodes.list',
},
],
},
{
'title': "Vendors",
'type': 'menu',
'items': [
{
'title': "Vendors",
'url': url('vendors'),
'perm': 'vendors.list',
},
{'type': 'sep'},
{
'title': "Catalogs",
'url': url('vendorcatalogs'),
'perm': 'vendorcatalogs.list',
},
{
'title': "Upload New Catalog",
'url': url('vendorcatalogs.create'),
'perm': 'vendorcatalogs.create',
},
],
},
{
'title': "Company",
'type': 'menu',
'items': [
{
'title': "Stores",
'url': url('stores'),
'perm': 'stores.list',
},
{
'title': "Departments",
'url': url('departments'),
'perm': 'departments.list',
},
{
'title': "Subdepartments",
'url': url('subdepartments'),
'perm': 'subdepartments.list',
},
{'type': 'sep'},
{
'title': "Employees",
'url': url('employees'),
'perm': 'employees.list',
},
{'type': 'sep'},
{
'title': "Customers",
'url': url('customers'),
'perm': 'customers.list',
},
{
'title': "Customer Groups",
'url': url('customergroups'),
'perm': 'customergroups.list',
},
],
},
{
'title': "Batches",
'type': 'menu',
'items': [
{
'title': "Handheld",
'url': url('batch.handheld'),
'perm': 'batch.handheld.list',
},
{
'title': "Inventory",
'url': url('batch.inventory'),
'perm': 'batch.inventory.list',
},
],
},
{
'title': "Admin",
'type': 'menu',
'items': [
{
'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': "Rattail Tutorial Upgrades",
'url': url('upgrades'),
'perm': 'upgrades.list',
},
],
},
]
return menus

View file

@ -0,0 +1,9 @@
# -*- coding: utf-8; mode: python -*-
"""
Static assets
"""
def includeme(config):
config.include('tailbone.static')
config.add_static_view('rattail_tutorial', 'rattail_tutorial.web:static', cache_max_age=3600)

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8; mode: python -*-
"""
Pyramid event subscribers
"""
from __future__ import unicode_literals, absolute_import
import rattail_tutorial
def add_rattail_tutorial_to_context(event):
renderer_globals = event
renderer_globals['rattail_tutorial'] = rattail_tutorial
def includeme(config):
config.include('tailbone.subscribers')
config.add_subscriber(add_rattail_tutorial_to_context, 'pyramid.events.BeforeRender')

View file

@ -0,0 +1,20 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/base_meta.mako" />
## default behavior is to read app_title from settings
## <%def name="app_title()">Rattail Tutorial</%def>
<%def name="favicon()">
## <link rel="icon" type="image/x-icon" href="${request.static_url('rattail_tutorial.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("Rattail Tutorial {}{}".format(rattail_tutorial.__version__, '' if request.rattail_config.production() else '+dev'), url('about'))}
</p>
</%def>

View file

@ -0,0 +1,14 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/home.mako" />
<%def name="title()">Home</%def>
<div class="logo">
## ${h.image(request.static_url('rattail_tutorial.web:static/img/rattail_tutorial.jpg'), "Rattail Tutorial Logo", id='logo', width=500)}
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo")}
</div>
<h1 style="text-align: center;">Welcome to Rattail Tutorial</h1>

View file

@ -0,0 +1,18 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/login.mako" />
<%def name="extra_styles()">
${parent.extra_styles()}
<style type="text/css">
#logo {
margin: 40px auto;
}
</style>
</%def>
<%def name="logo()">
## ${h.image(request.static_url('ratbob.web:static/img/ratbob.jpg'), "Ratbob Logo", id='logo', width=500)}
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo", id='logo')}
</%def>
${parent.body()}

View file

@ -0,0 +1,27 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/mobile/base.mako" />
<%def name="app_title()">Rattail Tutorial</%def>
<%def name="mobile_usermenu()">
<div id="usermenu" data-role="panel" data-display="overlay">
<ul data-role="listview">
<li data-icon="home">${h.link_to("Home", url('mobile.home'))}</li>
% if request.is_root:
<li class="root-user" data-icon="forbidden">${h.link_to("Stop being root", url('stop_root'), **{'data-ajax': 'false'})}</li>
% elif request.is_admin:
<li class="root-user" data-icon="forbidden">${h.link_to("Become root", url('become_root'), **{'data-ajax': 'false'})}</li>
% endif
<li data-icon="lock">${h.link_to("Logout", url('logout'), **{'data-ajax': 'false'})}</li>
<li data-icon="info">${h.link_to("About {}".format(capture(self.app_title)), url('mobile.about'))}</li>
</ul>
</div>
</%def>
<%def name="mobile_footer()">
<div data-role="footer">
<h4>${h.link_to("Rattail Tutorial {}{}".format(rattail_tutorial.__version__, '' if request.rattail_config.production() else '+dev'), url('mobile.about'))}</h4>
</div>
</%def>
${parent.body()}

View file

@ -0,0 +1,8 @@
## -*- coding: utf-8; mode: html; -*-
<%inherit file="tailbone:templates/mobile/home.mako" />
<div style="text-align: center;">
## ${h.image(request.static_url('rattail_tutorial.web:static/img/rattail_tutorial.jpg'), "Rattail Tutorial Logo", width='300')}
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo", width='400')}
<h3>Welcome to ${self.app_title()}</h3>
</div>

View file

@ -0,0 +1,40 @@
# -*- coding: utf-8; mode: python; -*-
"""
Views
"""
from __future__ import unicode_literals, absolute_import
def includeme(config):
# core views
config.include('rattail_tutorial.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.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.shifts')
config.include('tailbone.views.stores')
config.include('tailbone.views.subdepartments')
config.include('tailbone.views.users')
config.include('tailbone.views.vendors')
# batch views
config.include('tailbone.views.handheld')
config.include('tailbone.views.inventory')

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8; mode: python; -*-
"""
Common views
"""
from __future__ import unicode_literals, absolute_import
from tailbone.views import common as base
import rattail_tutorial
class CommonView(base.CommonView):
project_title = "Rattail Tutorial"
project_version = rattail_tutorial.__version__ + '+dev'
def includeme(config):
CommonView.defaults(config)

97
setup.py Normal file
View file

@ -0,0 +1,97 @@
# -*- coding: utf-8; mode: python -*-
"""
Rattail Tutorial setup script
"""
from __future__ import unicode_literals, absolute_import
import os
from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__))
exec(open(os.path.join(here, 'rattail_tutorial', '_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.6.2
'rattail', # 0.7.25
'Tailbone', # 0.5.29
]
setup(
name = "Rattail_tutorial",
version = __version__,
author = "Your Name",
author_email = "you@example.com",
# url = "",
description = "Rattail project for Your Company",
long_description = README,
classifiers = [
'Private :: Do Not Upload',
'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 :: 2.7',
'Topic :: Office/Business',
],
install_requires = requires,
packages = find_packages(),
include_package_data = True,
entry_points = {
'rattail.config.extensions': [
'rattail_tutorial = rattail_tutorial.config:Rattail_tutorialConfig',
],
'console_scripts': [
'rattail_tutorial = rattail_tutorial.commands:main',
],
'rattail_tutorial.commands': [
'hello = rattail_tutorial.commands:HelloWorld',
],
'paste.app_factory': [
'main = rattail_tutorial.web.app:main',
],
},
)