Morph project => rattail-demo

This commit is contained in:
Lance Edgar 2016-12-07 20:24:11 -06:00
parent a38c832dee
commit 220c6184aa
14 changed files with 219 additions and 162 deletions

2
.gitignore vendored
View file

@ -1 +1 @@
rattail_poser.egg-info/ rattail_demo.egg-info/

View file

@ -1,6 +1,6 @@
# -*- mode: conf -*- # -*- mode: conf -*-
recursive-include poser/web/static *.css recursive-include rattail_demo/web/static *.css
recursive-include poser/web/static *.js recursive-include rattail_demo/web/static *.js
recursive-include poser/web/templates *.mako recursive-include rattail_demo/web/templates *.mako

View file

@ -1,6 +1,6 @@
Rattail 'Poser' Rattail Demo
=============== ============
This project serves as a working demo, to illustrate various concepts of the This project serves as a working demo, to illustrate various concepts of the
Rattail software framework. See the `Rattail Wiki`_ for more info. Rattail software framework. See the `Rattail Wiki`_ for more info.

View file

@ -1,139 +0,0 @@
## -*- coding: utf-8 -*-
<%def name="main_menu_items()">
% if request.has_any_perm('schedule.view', 'timesheet.view'):
<li>
<a>Time Clock</a>
<ul>
% if request.has_perm('schedule.view'):
<li>${h.link_to("Employee Schedule", url('schedule.employee'))}</li>
% endif
% if request.has_perm('timesheet.view'):
<li>${h.link_to("Employee Time Sheet", url('timesheet.employee'))}</li>
% endif
% if request.has_any_perm('schedule.viewall', 'timesheet.viewall'):
<li>-</li>
% if request.has_perm('schedule.viewall'):
<li>${h.link_to("Full Schedule", url('schedule'))}</li>
% endif
% if request.has_perm('timesheet.viewall'):
<li>${h.link_to("Full Time Sheet", url('timesheet'))}</li>
% endif
% endif
</ul>
</li>
% endif
<li>
<a>Products</a>
<ul>
% if request.has_perm('products.list'):
<li>${h.link_to("Products", url('products'))}</li>
% endif
% if request.has_perm('brands.list'):
<li>${h.link_to("Brands", url('brands'))}</li>
% endif
% if request.has_perm('families.list'):
<li>${h.link_to("Families", url('families'))}</li>
% endif
% if request.has_perm('reportcodes.list'):
<li>${h.link_to("Report Codes", url('reportcodes'))}</li>
% endif
</ul>
</li>
<li>
<a>Vendors</a>
<ul>
<li>${h.link_to("Vendors", url('vendors'))}</li>
% if request.has_any_perm('vendorcatalogs.list', 'vendorcatalogs.create'):
<li>-</li>
% if request.has_perm('vendorcatalogs.list'):
<li>${h.link_to("Catalogs", url('vendorcatalogs'))}</li>
% endif
% if request.has_perm('vendorcatalogs.create'):
<li>${h.link_to("Upload New Catalog", url('vendorcatalogs.create'))}</li>
% endif
% endif
</ul>
</li>
<li>
<a>Company</a>
<ul>
<li>${h.link_to("Stores", url('stores'))}</li>
<li>${h.link_to("Departments", url('departments'))}</li>
<li>${h.link_to("Subdepartments", url('subdepartments'))}</li>
<li>-</li>
<li>${h.link_to("Employees", url('employees'))}</li>
<li>-</li>
<li>${h.link_to("Customers", url('customers'))}</li>
% if request.has_perm('customergroups.list'):
<li>${h.link_to("Customer Groups", url('customergroups'))}</li>
% endif
</ul>
</li>
<li>
<a>Reports</a>
<ul>
<li>${h.link_to("Ordering Worksheet", url('reports.ordering'))}</li>
<li>${h.link_to("Inventory Worksheet", url('reports.inventory'))}</li>
</ul>
</li>
% if request.has_any_perm('batch.handheld.list', 'batch.inventory.list'):
<li>
<a>Batches</a>
<ul>
% if request.has_perm('batch.handheld.list'):
<li>${h.link_to("Handheld", url('batch.handheld'))}</li>
% endif
% if request.has_perm('batch.inventory.list'):
<li>${h.link_to("Inventory", url('batch.inventory'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('users.list', 'roles.list', 'labelprofiles.list', 'settings.list', 'emailprofiles.list', 'datasyncchanges.list'):
<li>
<a>Admin</a>
<ul>
% if request.has_perm('users.list'):
<li>${h.link_to("Users", url('users'))}</li>
% endif
% if request.has_perm('roles.list'):
<li>${h.link_to("Roles", url('roles'))}</li>
% endif
% if request.has_perm('labelprofiles.list'):
<li>${h.link_to("Label Profiles", url('labelprofiles'))}</li>
% endif
% if request.has_perm('settings.list'):
<li>${h.link_to("Settings", url('settings'))}</li>
% endif
% if request.has_perm('emailprofiles.list'):
<li>${h.link_to("Email Profiles", url('emailprofiles'))}</li>
% endif
% if request.has_perm('datasyncchanges.list'):
<li>${h.link_to("DataSync Changes", url('datasyncchanges'))}</li>
% endif
</ul>
</li>
% endif
% if request.user:
<li>
<a>${request.user}${" ({})".format(inbox_count) if inbox_count else ''}</a>
<ul>
<li>${h.link_to("Messages{}".format(" ({})".format(inbox_count) if inbox_count else ''), url('messages.inbox'))}</li>
<li>${h.link_to("Change Password", url('change_password'))}</li>
<li>${h.link_to("Logout", url('logout'))}</li>
</ul>
</li>
% else:
<li>${h.link_to("Login", url('login'))}</li>
% endif
</%def>

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Rattail 'Poser' (demo project) Rattail Demo
""" """
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import

View file

@ -15,8 +15,8 @@ def main(global_config, **settings):
# set some defaults for PostgreSQL # set some defaults for PostgreSQL
app.provide_postgresql_settings(settings) app.provide_postgresql_settings(settings)
# prefer Poser templates over Tailbone; use 'better' theme # prefer demo templates over tailbone; use 'better' theme
settings.setdefault('mako.directories', ['poser.web:templates', settings.setdefault('mako.directories', ['rattail_demo.web:templates',
'tailbone:templates/themes/better', 'tailbone:templates/themes/better',
'tailbone:templates',]) 'tailbone:templates',])
@ -24,15 +24,10 @@ def main(global_config, **settings):
rattail_config = app.make_rattail_config(settings) rattail_config = app.make_rattail_config(settings)
pyramid_config = app.make_pyramid_config(settings) pyramid_config = app.make_pyramid_config(settings)
# bring in the rest of Tailbone # bring in rest of rattail-demo etc.
pyramid_config.include('tailbone.static') pyramid_config.include('tailbone.static')
pyramid_config.include('tailbone.subscribers') pyramid_config.include('tailbone.subscribers')
pyramid_config.include('tailbone.views') pyramid_config.include('rattail_demo.web.views')
# # bring in the rest of Poser
# pyramid_config.include('poser.web.subscribers')
# pyramid_config.include('poser.web.static')
# pyramid_config.include('poser.web.views')
# configure PostgreSQL some more # configure PostgreSQL some more
app.configure_postgresql(pyramid_config) app.configure_postgresql(pyramid_config)

View file

@ -0,0 +1,14 @@
## -*- coding: utf-8 -*-
<%inherit file="tailbone:templates/themes/better/base.mako" />
<%def name="global_title()">${"[STAGE] " if not request.rattail_config.production() else ''}Rattail Demo</%def>
<%def name="favicon()">
<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", height='49')}
</%def>
${parent.body()}

View file

@ -0,0 +1,7 @@
## -*- coding: utf-8 -*-
<%inherit file="tailbone:templates/home.mako" />
<div class="logo">
${h.image(request.static_url('tailbone:static/img/home_logo.png'), "Rattail Logo")}
<h1>Welcome to the Rattail Demo</h1>
</div>

View file

@ -0,0 +1,110 @@
## -*- coding: utf-8 -*-
<%def name="main_menu_items()">
% if request.has_any_perm('products.list', 'vendors.list', 'brands.list', 'families.list', 'reportcodes.list'):
<li>
<a>Products</a>
<ul>
% if request.has_perm('products.list'):
<li>${h.link_to("Products", url('products'))}</li>
% endif
% if request.has_perm('vendors.list'):
<li>${h.link_to("Vendors", url('vendors'))}</li>
% endif
% if request.has_perm('brands.list'):
<li>${h.link_to("Brands", url('brands'))}</li>
% endif
% if request.has_perm('families.list'):
<li>${h.link_to("Families", url('families'))}</li>
% endif
% if request.has_perm('reportcodes.list'):
<li>${h.link_to("Report Codes", url('reportcodes'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('people.list', 'customers.list', 'employees.list'):
<li>
<a>People</a>
<ul>
% if request.has_perm('people.list'):
<li>${h.link_to("All People", url('people'))}</li>
% endif
% if request.has_perm('customers.list'):
<li>${h.link_to("Customers", url('customers'))}</li>
% endif
% if request.has_perm('employees.list'):
<li>${h.link_to("Employees", url('employees'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('stores.list', 'departments.list', 'subdepartments.list'):
<li>
<a>Company</a>
<ul>
% if request.has_perm('stores.list'):
<li>${h.link_to("Stores", url('stores'))}</li>
% endif
% if request.has_perm('departments.list'):
<li>${h.link_to("Departments", url('departments'))}</li>
% endif
% if request.has_perm('subdepartments.list'):
<li>${h.link_to("Subdepartments", url('subdepartments'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('batch.handheld.list', 'batch.inventory.list'):
<li>
<a>Batches</a>
<ul>
% if request.has_perm('batch.handheld.list'):
<li>${h.link_to("Handheld", url('batch.handheld'))}</li>
% endif
% if request.has_perm('batch.inventory.list'):
<li>${h.link_to("Inventory", url('batch.inventory'))}</li>
% endif
</ul>
</li>
% endif
% if request.has_any_perm('users.list', 'roles.list', 'settings.list'):
<li>
<a>Admin</a>
<ul>
% if request.has_perm('users.list'):
<li>${h.link_to("Users", url('users'))}</li>
% endif
% if request.has_perm('roles.list'):
<li>${h.link_to("Roles", url('roles'))}</li>
% endif
% if request.has_perm('settings.list'):
<li>${h.link_to("Settings", url('settings'))}</li>
% endif
</ul>
</li>
% endif
% if request.user:
<li>
<a${' class="root-user"' if request.is_root else ''|n}>${request.user}${" ({})".format(inbox_count) if inbox_count else ''}</a>
<ul>
% if request.is_root:
<li class="root-user">${h.link_to("Stop being root", url('stop_root'))}</li>
% elif request.is_admin:
<li class="root-user">${h.link_to("Become root", url('become_root'))}</li>
% endif
<li>${h.link_to("Change Password", url('change_password'))}</li>
<li>${h.link_to("Logout", url('logout'))}</li>
</ul>
</li>
% else:
<li>${h.link_to("Login", url('login'))}</li>
% endif
</%def>

View file

@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
"""
Web views
"""
from __future__ import unicode_literals, absolute_import
from tailbone import views as base
def bogus_error(request):
"""
A special view which simply raises an error, for the sake of testing
uncaught exception handling.
"""
raise Exception("Congratulations, you have triggered a bogus error.")
def includeme(config):
config.add_route('home', '/')
config.add_view(base.home, route_name='home', renderer='/home.mako')
config.add_route('bogus_error', '/bogus-error')
config.add_view(bogus_error, route_name='bogus_error',
permission='admin')
# TODO: merge above views into common
# core views
config.include('rattail_demo.web.views.common')
config.include('tailbone.views.auth')
# main table views
config.include('tailbone.views.brands')
config.include('tailbone.views.customers')
config.include('tailbone.views.departments')
config.include('tailbone.views.employees')
config.include('tailbone.views.families')
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')
# batch views
config.include('tailbone.views.handheld')
config.include('tailbone.views.inventory')

View file

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

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Setup script for Rattail 'Poser' Setup script for Rattail Demo
""" """
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
@ -10,7 +10,7 @@ from setuptools import setup, find_packages
here = os.path.abspath(os.path.dirname(__file__)) here = os.path.abspath(os.path.dirname(__file__))
execfile(os.path.join(here, 'poser', '_version.py')) execfile(os.path.join(here, 'rattail_demo', '_version.py'))
README = open(os.path.join(here, 'README.rst')).read() README = open(os.path.join(here, 'README.rst')).read()
@ -44,12 +44,13 @@ requires = [
# package # low high # package # low high
'psycopg2', # 2.6.2 'psycopg2', # 2.6.2
'rattail', # 0.7.25 'Tailbone', # 0.5.49
'xlrd', # 1.0.0
] ]
setup( setup(
name = "rattail-poser", name = "rattail-demo",
version = __version__, version = __version__,
author = "Lance Edgar", author = "Lance Edgar",
author_email = "lance@edbob.org", author_email = "lance@edbob.org",
@ -58,9 +59,7 @@ setup(
long_description = README, long_description = README,
classifiers = [ classifiers = [
'Private :: Do No Upload',
'Development Status :: 3 - Alpha', 'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'Natural Language :: English', 'Natural Language :: English',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
@ -75,7 +74,7 @@ setup(
entry_points = { entry_points = {
'paste.app_factory': [ 'paste.app_factory': [
'main = poser.web.app:main', 'main = rattail_demo.web.app:main',
], ],
}, },
) )