diff --git a/rattail/pyramid/__init__.py b/rattail/pyramid/__init__.py
index a87d0d10..e188d283 100644
--- a/rattail/pyramid/__init__.py
+++ b/rattail/pyramid/__init__.py
@@ -26,53 +26,9 @@
``rattail.pyramid`` -- Rattail's Pyramid Framework
"""
-# import os.path
-
-# import pyramid_beaker
-# from pyramid.config import Configurator
-
-# import edbob
-
from rattail.pyramid._version import __version__
-# def main(global_config, **settings):
-# """
-# This function returns a Pyramid WSGI application.
-# """
-
-# # Here you can insert any code to modify the ``settings`` dict.
-# # You can:
-# # * Add additional keys to serve as constants or "global variables" in the
-# # application.
-# # * Set default values for settings that may have been omitted.
-# # * Override settings that you don't want the user to change.
-# # * Raise an exception if a setting is missing or invalid.
-# # * Convert values from strings to their intended type.
-
-# settings['mako.directories'] = [
-# 'something:templates',
-# 'edbob.pyramid:templates',
-# ]
-
-# # Configure Pyramid
-# config = Configurator(settings=settings)
-# config.include('edbob.pyramid')
-# config.include('something.subscribers')
-# config.scan()
-
-# # Configure Beaker
-# session_factory = pyramid_beaker.session_factory_from_settings(settings)
-# config.set_session_factory(session_factory)
-# pyramid_beaker.set_cache_regions_from_settings(settings)
-
-# # Configure edbob
-# edbob.basic_logging()
-# edbob.init('something', os.path.abspath(settings['edbob.config']))
-
-# # Add static views
-# # config.add_static_view('css', 'static/css', cache_max_age=3600)
-# # config.add_static_view('img', 'static/img', cache_max_age=3600)
-# # config.add_static_view('js', 'static/js', cache_max_age=3600)
-
-# return config.make_wsgi_app()
+def includeme(config):
+ config.include('rattail.pyramid.subscribers')
+ config.include('rattail.pyramid.views')
diff --git a/rattail/pyramid/templates/customer_groups/crud.mako b/rattail/pyramid/templates/customer_groups/crud.mako
new file mode 100644
index 00000000..0c0ba7cb
--- /dev/null
+++ b/rattail/pyramid/templates/customer_groups/crud.mako
@@ -0,0 +1,7 @@
+<%inherit file="/crud.mako" />
+
+<%def name="context_menu_items()">
+
${h.link_to("Back to Customer Groups", url('customer_groups'))}
+%def>
+
+${parent.body()}
diff --git a/rattail/pyramid/templates/customers/read.mako b/rattail/pyramid/templates/customers/read.mako
index 10bf43c9..c5cfa315 100644
--- a/rattail/pyramid/templates/customers/read.mako
+++ b/rattail/pyramid/templates/customers/read.mako
@@ -7,7 +7,7 @@ ${parent.body()}
People
% if customer.people:
Customer account is associated with the following people:
-
+
First Name |
@@ -15,7 +15,7 @@ ${parent.body()}
% for i, person in enumerate(customer.people, 1):
-
+
${person.first_name or ''} |
${person.last_name or ''} |
@@ -30,7 +30,7 @@ ${parent.body()}
Groups
% if customer.groups:
Customer account belongs to the following groups:
-
+
ID |
@@ -38,7 +38,7 @@ ${parent.body()}
% for i, group in enumerate(customer.groups, 1):
-
+
${group.id} |
${group.name or ''} |
diff --git a/rattail/pyramid/templates/stores/crud.mako b/rattail/pyramid/templates/stores/crud.mako
new file mode 100644
index 00000000..7c690077
--- /dev/null
+++ b/rattail/pyramid/templates/stores/crud.mako
@@ -0,0 +1,7 @@
+<%inherit file="/crud.mako" />
+
+<%def name="context_menu_items()">
+ ${h.link_to("Back to Stores", url('stores'))}
+%def>
+
+${parent.body()}
diff --git a/rattail/pyramid/templates/stores/index.mako b/rattail/pyramid/templates/stores/index.mako
new file mode 100644
index 00000000..d2e76951
--- /dev/null
+++ b/rattail/pyramid/templates/stores/index.mako
@@ -0,0 +1,11 @@
+<%inherit file="/grid.mako" />
+
+<%def name="title()">Stores%def>
+
+<%def name="context_menu_items()">
+ % if request.has_perm('stores.create'):
+ ${h.link_to("Create a new Store", url('store.create'))}
+ % endif
+%def>
+
+${parent.body()}
diff --git a/rattail/pyramid/views/__init__.py b/rattail/pyramid/views/__init__.py
index 86bc1d47..c853b560 100644
--- a/rattail/pyramid/views/__init__.py
+++ b/rattail/pyramid/views/__init__.py
@@ -1,36 +1,41 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-################################################################################
-#
-# Rattail -- Retail Software Framework
-# Copyright © 2010-2012 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 Affero 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 Affero General Public License for
-# more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Rattail. If not, see .
-#
-################################################################################
-
-"""
-``rattail.pyramid.views`` -- Pyramid Views
-"""
-
-
-def includeme(config):
- config.include('rattail.pyramid.views.batches')
- config.include('rattail.pyramid.views.departments')
- config.include('rattail.pyramid.views.categories')
- config.include('rattail.pyramid.views.products')
- config.include('rattail.pyramid.views.employees')
- config.include('rattail.pyramid.views.vendors')
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+################################################################################
+#
+# Rattail -- Retail Software Framework
+# Copyright © 2010-2012 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 Affero 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 Affero General Public License for
+# more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Rattail. If not, see .
+#
+################################################################################
+
+"""
+``rattail.pyramid.views`` -- Pyramid Views
+"""
+
+
+def includeme(config):
+ config.include('rattail.pyramid.views.batches')
+ # config.include('rattail.pyramid.views.categories')
+ config.include('rattail.pyramid.views.customer_groups')
+ config.include('rattail.pyramid.views.customers')
+ config.include('rattail.pyramid.views.departments')
+ config.include('rattail.pyramid.views.employees')
+ config.include('rattail.pyramid.views.labels')
+ config.include('rattail.pyramid.views.products')
+ config.include('rattail.pyramid.views.stores')
+ config.include('rattail.pyramid.views.subdepartments')
+ config.include('rattail.pyramid.views.vendors')
diff --git a/rattail/pyramid/views/customer_groups.py b/rattail/pyramid/views/customer_groups.py
index 9b561604..83056dcc 100644
--- a/rattail/pyramid/views/customer_groups.py
+++ b/rattail/pyramid/views/customer_groups.py
@@ -26,7 +26,7 @@
``rattail.pyramid.views.customergroups`` -- CustomerGroup Views
"""
-from edbob.pyramid.views import SearchableAlchemyGridView, AlchemyGridView
+from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
import rattail
@@ -59,9 +59,30 @@ class CustomerGroupsGrid(SearchableAlchemyGridView):
return g
+class CustomerGroupCrud(CrudView):
+
+ mapped_class = rattail.CustomerGroup
+ home_route = 'customer_groups'
+ pretty_name = "Customer Group"
+
+ def fieldset(self, model):
+ fs = self.make_fieldset(model)
+ fs.configure(
+ include=[
+ fs.id.label("ID"),
+ fs.name,
+ ])
+ return fs
+
+
def includeme(config):
config.add_route('customer_groups', '/customer-groups')
config.add_view(CustomerGroupsGrid, route_name='customer_groups',
renderer='/customer_groups/index.mako',
permission='customer_groups.list')
+
+ config.add_route('customer_group.read', '/customer-groups/{uuid}')
+ config.add_view(CustomerGroupCrud, attr='read', route_name='customer_group.read',
+ renderer='/customer_groups/crud.mako',
+ permission='customer_groups.read')
diff --git a/rattail/pyramid/views/customers.py b/rattail/pyramid/views/customers.py
index 589f5c2a..c02344a4 100644
--- a/rattail/pyramid/views/customers.py
+++ b/rattail/pyramid/views/customers.py
@@ -28,7 +28,9 @@
from sqlalchemy import and_
+import edbob
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
+from edbob.pyramid.forms import EnumFieldRenderer
import rattail
@@ -94,12 +96,14 @@ class CustomerCrud(CrudView):
def fieldset(self, model):
fs = self.make_fieldset(model)
+ fs.email_preference.set(renderer=EnumFieldRenderer(edbob.EMAIL_PREFERENCE))
fs.configure(
include=[
fs.id.label("ID"),
fs.name,
- fs.phone,
- fs.email,
+ fs.phone.label("Phone Number"),
+ fs.email.label("Email Address"),
+ fs.email_preference,
])
return fs
diff --git a/rattail/pyramid/views/stores.py b/rattail/pyramid/views/stores.py
new file mode 100644
index 00000000..476acadd
--- /dev/null
+++ b/rattail/pyramid/views/stores.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+################################################################################
+#
+# Rattail -- Retail Software Framework
+# Copyright © 2010-2012 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 Affero 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 Affero General Public License for
+# more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Rattail. If not, see .
+#
+################################################################################
+
+"""
+``rattail.pyramid.views.stores`` -- Store Views
+"""
+
+from sqlalchemy import and_
+
+from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
+
+import rattail
+
+
+class StoresGrid(SearchableAlchemyGridView):
+
+ mapped_class = rattail.Store
+ config_prefix = 'stores'
+ sort = 'name'
+
+ def join_map(self):
+ return {
+ 'email':
+ lambda q: q.outerjoin(rattail.StoreEmailAddress, and_(
+ rattail.StoreEmailAddress.parent_uuid == rattail.Store.uuid,
+ rattail.StoreEmailAddress.preference == 1)),
+ 'phone':
+ lambda q: q.outerjoin(rattail.StorePhoneNumber, and_(
+ rattail.StorePhoneNumber.parent_uuid == rattail.Store.uuid,
+ rattail.StorePhoneNumber.preference == 1)),
+ }
+
+ def filter_map(self):
+ return self.make_filter_map(
+ exact=['id'],
+ ilike=['name'],
+ email=self.filter_ilike(rattail.StoreEmailAddress.address),
+ phone=self.filter_ilike(rattail.StorePhoneNumber.number))
+
+ def filter_config(self):
+ return self.make_filter_config(
+ include_filter_name=True,
+ filter_type_name='lk',
+ filter_label_id="ID")
+
+ def sort_map(self):
+ return self.make_sort_map(
+ 'id', 'name',
+ email=self.sorter(rattail.StoreEmailAddress.address),
+ phone=self.sorter(rattail.StorePhoneNumber.number))
+
+ def grid(self):
+ g = self.make_grid()
+ g.configure(
+ include=[
+ g.id.label("ID"),
+ g.name,
+ g.phone.label("Phone Number"),
+ g.email.label("Email Address"),
+ ],
+ readonly=True)
+ g.clickable = True
+ g.click_route_name = 'store.read'
+ if self.request.has_perm('stores.update'):
+ g.editable = True
+ g.edit_route_name = 'store.update'
+ if self.request.has_perm('stores.delete'):
+ g.deletable = True
+ g.delete_route_name = 'store.delete'
+ return g
+
+
+class StoreCrud(CrudView):
+
+ mapped_class = rattail.Store
+ home_route = 'stores'
+
+ def fieldset(self, model):
+ fs = self.make_fieldset(model)
+ fs.configure(
+ include=[
+ fs.id.label("ID"),
+ fs.name,
+ fs.phone.label("Phone Number").readonly(),
+ fs.email.label("Email Address").readonly(),
+ ])
+ return fs
+
+
+def includeme(config):
+
+ config.add_route('stores', '/stores')
+ config.add_view(StoresGrid, route_name='stores',
+ renderer='/stores/index.mako',
+ permission='stores.list')
+
+ config.add_route('store.create', '/stores/new')
+ config.add_view(StoreCrud, attr='create', route_name='store.create',
+ renderer='/stores/crud.mako',
+ permission='stores.create')
+
+ config.add_route('store.read', '/stores/{uuid}')
+ config.add_view(StoreCrud, attr='read', route_name='store.read',
+ renderer='/stores/crud.mako',
+ permission='stores.read')
+
+ config.add_route('store.update', '/stores/{uuid}/edit')
+ config.add_view(StoreCrud, attr='update', route_name='store.update',
+ renderer='/stores/crud.mako',
+ permission='stores.update')
+
+ config.add_route('store.delete', '/stores/{uuid}/delete')
+ config.add_view(StoreCrud, attr='delete', route_name='store.delete',
+ permission='stores.delete')
diff --git a/setup.py b/setup.py
index 70307f3a..b6b4365c 100644
--- a/setup.py
+++ b/setup.py
@@ -62,26 +62,8 @@ requires = [
#
# package # low high
- # Beaker dependency included here because 'pyramid_beaker' uses incorrect
- # case in its requirement declaration.
- 'Beaker', # 1.6.3
-
- # Pyramid 1.3 introduced 'pcreate' command (and friends) to replace
- # deprecated 'paster create' (and friends).
- 'pyramid>=1.3a1', # 1.3b2
-
- 'decorator', # 3.3.2
- 'Mako', # 0.6.2
- 'pyramid_beaker', # 0.6.1
- 'pyramid_debugtoolbar', # 1.0
- 'pyramid_tm', # 0.3
+ 'edbob[db,pyramid]>=0.1a13', # 0.1a14.dev
'rattail>=0.3a4', # 0.3a5.dev
- 'SQLAlchemy', # 0.7.6
- 'Tempita', # 0.5.1
- 'transaction', # 1.2.0
- 'waitress', # 0.8.1
- 'WebHelpers', # 1.3
- 'zope.sqlalchemy', # 0.7
]