update grid, crud views per edbob changes
This commit is contained in:
parent
59c8da5690
commit
dcbcf81c40
|
@ -1,4 +1,4 @@
|
||||||
<%inherit file="/index.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
|
|
||||||
<%def name="title()">Customer Groups</%def>
|
<%def name="title()">Customer Groups</%def>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%inherit file="/index.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
|
|
||||||
<%def name="title()">Customers</%def>
|
<%def name="title()">Customers</%def>
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
||||||
|
<% customer = form.fieldset.model %>
|
||||||
|
|
||||||
<h2>People</h2>
|
<h2>People</h2>
|
||||||
% if fieldset.model.people:
|
% if customer.people:
|
||||||
<p>Customer account is associated with the following people:</p>
|
<p>Customer account is associated with the following people:</p>
|
||||||
<div class="grid hoverable">
|
<div class="grid hoverable">
|
||||||
<table>
|
<table>
|
||||||
|
@ -12,7 +14,7 @@ ${parent.body()}
|
||||||
<th>Last Name</th>
|
<th>Last Name</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
% for i, person in enumerate(fieldset.model.people, 1):
|
% for i, person in enumerate(customer.people, 1):
|
||||||
<tr class="${'odd' if i % 2 else 'even'}">
|
<tr class="${'odd' if i % 2 else 'even'}">
|
||||||
<td>${person.first_name or ''}</td>
|
<td>${person.first_name or ''}</td>
|
||||||
<td>${person.last_name or ''}</td>
|
<td>${person.last_name or ''}</td>
|
||||||
|
@ -26,7 +28,7 @@ ${parent.body()}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
<h2>Groups</h2>
|
<h2>Groups</h2>
|
||||||
% if fieldset.model.groups:
|
% if customer.groups:
|
||||||
<p>Customer account belongs to the following groups:</p>
|
<p>Customer account belongs to the following groups:</p>
|
||||||
<div class="grid hoverable">
|
<div class="grid hoverable">
|
||||||
<table>
|
<table>
|
||||||
|
@ -35,7 +37,7 @@ ${parent.body()}
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
% for i, group in enumerate(fieldset.model.groups, 1):
|
% for i, group in enumerate(customer.groups, 1):
|
||||||
<tr class="${'odd' if i % 2 else 'even'}">
|
<tr class="${'odd' if i % 2 else 'even'}">
|
||||||
<td>${group.id}</td>
|
<td>${group.id}</td>
|
||||||
<td>${group.name or ''}</td>
|
<td>${group.name or ''}</td>
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/base.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,5 +1,4 @@
|
||||||
<%inherit file="/departments/base.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
<%inherit file="/index.mako" />
|
|
||||||
|
|
||||||
<%def name="title()">Departments</%def>
|
<%def name="title()">Departments</%def>
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/base.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,8 +0,0 @@
|
||||||
<%inherit file="/employees/base.mako" />
|
|
||||||
<%inherit file="/crud.mako" />
|
|
||||||
|
|
||||||
<%def name="menu()">
|
|
||||||
<p>${h.link_to("Back to Employees", url('employees.list'))}</p>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
${parent.body()}
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/employees/crud.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,12 +1,5 @@
|
||||||
<%inherit file="/employees/base.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
<%inherit file="/index.mako" />
|
|
||||||
|
|
||||||
<%def name="title()">Employees</%def>
|
<%def name="title()">Employees</%def>
|
||||||
|
|
||||||
<%def name="menu()">
|
|
||||||
% if request.has_perm('employees.create'):
|
|
||||||
<p>${h.link_to("Create a new Employee", url('employees.new'))}</p>
|
|
||||||
% endif
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/employees/crud.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/base.mako" />
|
|
||||||
${parent.body()}
|
|
|
@ -1,7 +1,7 @@
|
||||||
<%inherit file="/crud.mako" />
|
<%inherit file="/crud.mako" />
|
||||||
|
|
||||||
<%def name="context_menu_items()">
|
<%def name="context_menu_items()">
|
||||||
<p>${h.link_to("Back to Products", url('products'))}</p>
|
<li>${h.link_to("Back to Products", url('products'))}</li>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<%inherit file="/products/base.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
<%inherit file="/index.mako" />
|
|
||||||
|
|
||||||
<%def name="title()">Products</%def>
|
<%def name="title()">Products</%def>
|
||||||
|
|
||||||
|
@ -7,17 +6,17 @@
|
||||||
${parent.head_tags()}
|
${parent.head_tags()}
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
|
||||||
table.header td.tools table {
|
table.grid-header td.tools table {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.header td.tools table th,
|
table.grid-header td.tools table th,
|
||||||
table.header td.tools table td {
|
table.grid-header td.tools table td {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.header td.tools table #label-quantity {
|
table.grid-header td.tools table #label-quantity {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,12 @@
|
||||||
<%inherit file="/products/crud.mako" />
|
<%inherit file="/products/crud.mako" />
|
||||||
|
|
||||||
<%def name="head_tags()">
|
|
||||||
${parent.head_tags()}
|
|
||||||
<style type="text/css">
|
|
||||||
|
|
||||||
#product-costs td.center {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
||||||
|
<% product = form.fieldset.model %>
|
||||||
|
|
||||||
<div id="product-costs">
|
<div id="product-costs">
|
||||||
<h2>Product Costs:</h2>
|
<h2>Product Costs:</h2>
|
||||||
% if fieldset.model.costs:
|
% if product.costs:
|
||||||
<div class="grid hoverable">
|
<div class="grid hoverable">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -27,7 +18,7 @@ ${parent.body()}
|
||||||
<th>Unit Cost</th>
|
<th>Unit Cost</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
% for i, cost in enumerate(fieldset.model.costs, 1):
|
% for i, cost in enumerate(product.costs, 1):
|
||||||
<tr class="${'odd' if i % 2 else 'even'}">
|
<tr class="${'odd' if i % 2 else 'even'}">
|
||||||
<td class="center">${'X' if cost.preference == 1 else ''}</td>
|
<td class="center">${'X' if cost.preference == 1 else ''}</td>
|
||||||
<td>${cost.vendor}</td>
|
<td>${cost.vendor}</td>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%inherit file="/index.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
|
|
||||||
<%def name="title()">Subdepartments</%def>
|
<%def name="title()">Subdepartments</%def>
|
||||||
|
|
||||||
|
|
2
rattail/pyramid/templates/vendors/base.mako
vendored
2
rattail/pyramid/templates/vendors/base.mako
vendored
|
@ -1,2 +0,0 @@
|
||||||
<%inherit file="/base.mako" />
|
|
||||||
${parent.body()}
|
|
3
rattail/pyramid/templates/vendors/index.mako
vendored
3
rattail/pyramid/templates/vendors/index.mako
vendored
|
@ -1,5 +1,4 @@
|
||||||
<%inherit file="/vendors/base.mako" />
|
<%inherit file="/grid.mako" />
|
||||||
<%inherit file="/index.mako" />
|
|
||||||
|
|
||||||
<%def name="title()">Vendors</%def>
|
<%def name="title()">Vendors</%def>
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,7 @@ import rattail
|
||||||
class CustomerGroupsGrid(SearchableAlchemyGridView):
|
class CustomerGroupsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.CustomerGroup
|
mapped_class = rattail.CustomerGroup
|
||||||
route_name = 'customergroups'
|
config_prefix = 'customer_groups'
|
||||||
route_url = '/customergroups'
|
|
||||||
renderer = '/customergroups/index.mako'
|
|
||||||
permission = 'customergroups.list'
|
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
@ -63,4 +60,8 @@ class CustomerGroupsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
CustomerGroupsGrid.add_route(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')
|
|
@ -28,8 +28,7 @@
|
||||||
|
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
|
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView
|
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
|
||||||
from edbob.pyramid.views.crud import Crud
|
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
|
|
||||||
|
@ -37,10 +36,7 @@ import rattail
|
||||||
class CustomersGrid(SearchableAlchemyGridView):
|
class CustomersGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Customer
|
mapped_class = rattail.Customer
|
||||||
route_name = 'customers'
|
config_prefix = 'customers'
|
||||||
route_url = '/customers'
|
|
||||||
renderer = '/customers/index.mako'
|
|
||||||
permission = 'customers.list'
|
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
clickable = True
|
clickable = True
|
||||||
|
|
||||||
|
@ -87,20 +83,17 @@ class CustomersGrid(SearchableAlchemyGridView):
|
||||||
g.email.label("Email Address"),
|
g.email.label("Email Address"),
|
||||||
],
|
],
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
g.click_route_name = 'customer.read'
|
||||||
g.row_route_name = 'customer.read'
|
|
||||||
g.row_route_kwargs = lambda x: {'uuid': x.uuid}
|
|
||||||
|
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
class CustomerCrud(Crud):
|
class CustomerCrud(CrudView):
|
||||||
|
|
||||||
mapped_class = rattail.Customer
|
mapped_class = rattail.Customer
|
||||||
home_route = 'customers'
|
home_route = 'customers'
|
||||||
|
|
||||||
def fieldset(self, obj):
|
def fieldset(self, model):
|
||||||
fs = self.make_fieldset(obj)
|
fs = self.make_fieldset(model)
|
||||||
fs.configure(
|
fs.configure(
|
||||||
include=[
|
include=[
|
||||||
fs.id.label("ID"),
|
fs.id.label("ID"),
|
||||||
|
@ -112,5 +105,13 @@ class CustomerCrud(Crud):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
CustomersGrid.add_route(config)
|
|
||||||
CustomerCrud.add_routes(config)
|
config.add_route('customers', '/customers')
|
||||||
|
config.add_view(CustomersGrid, route_name='customers',
|
||||||
|
renderer='/customers/index.mako',
|
||||||
|
permission='customers.list')
|
||||||
|
|
||||||
|
config.add_route('customer.read', '/customers/{uuid}')
|
||||||
|
config.add_view(CustomerCrud, attr='read', route_name='customer.read',
|
||||||
|
renderer='/customers/read.mako',
|
||||||
|
permission='customers.read')
|
||||||
|
|
|
@ -26,37 +26,16 @@
|
||||||
``rattail.pyramid.views.departments`` -- Department Views
|
``rattail.pyramid.views.departments`` -- Department Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# import transaction
|
|
||||||
# from pyramid.httpexceptions import HTTPFound
|
|
||||||
# from pyramid.view import view_config
|
|
||||||
|
|
||||||
# from edbob.pyramid import Session
|
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView, AlchemyGridView
|
from edbob.pyramid.views import SearchableAlchemyGridView, AlchemyGridView
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
|
|
||||||
|
|
||||||
# @view_config(route_name='department.delete')
|
|
||||||
# def delete_department(context, request):
|
|
||||||
# uuid = request.matchdict['uuid']
|
|
||||||
# dept = Session.query(rattail.Department).get(uuid) if uuid else None
|
|
||||||
# assert dept
|
|
||||||
# with transaction.manager:
|
|
||||||
# q = Session.query(rattail.Product)
|
|
||||||
# q = q.filter(rattail.Product.department_uuid == dept.uuid)
|
|
||||||
# if q.count():
|
|
||||||
# q.update({'department_uuid': None}, synchronize_session=False)
|
|
||||||
# Session.delete(dept)
|
|
||||||
# return HTTPFound(location=request.route_url('departments.list'))
|
|
||||||
|
|
||||||
|
|
||||||
class DepartmentsGrid(SearchableAlchemyGridView):
|
class DepartmentsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Department
|
mapped_class = rattail.Department
|
||||||
route_name = 'departments'
|
config_prefix = 'departments'
|
||||||
route_url = '/departments'
|
|
||||||
renderer = '/departments/index.mako'
|
|
||||||
permission = 'departments.list'
|
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
@ -84,8 +63,7 @@ class DepartmentsGrid(SearchableAlchemyGridView):
|
||||||
class DepartmentsByVendorGrid(AlchemyGridView):
|
class DepartmentsByVendorGrid(AlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Department
|
mapped_class = rattail.Department
|
||||||
route_name = 'departments.by_vendor'
|
config_prefix = 'departments.by_vendor'
|
||||||
route_url = '/departments/by-vendor'
|
|
||||||
checkboxes = True
|
checkboxes = True
|
||||||
partial_only = True
|
partial_only = True
|
||||||
|
|
||||||
|
@ -110,8 +88,12 @@ class DepartmentsByVendorGrid(AlchemyGridView):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
# config.add_route('department.delete', '/department/{uuid}/delete')
|
|
||||||
# config.scan(__name__)
|
|
||||||
|
|
||||||
DepartmentsGrid.add_route(config)
|
config.add_route('departments', '/departments')
|
||||||
DepartmentsByVendorGrid.add_route(config)
|
config.add_view(DepartmentsGrid, route_name='departments',
|
||||||
|
renderer='/departments/index.mako',
|
||||||
|
permission='departments.list')
|
||||||
|
|
||||||
|
config.add_route('departments.by_vendor', '/departments/by-vendor')
|
||||||
|
config.add_view(DepartmentsByVendorGrid, route_name='departments.by_vendor',
|
||||||
|
permission='departments.list')
|
||||||
|
|
|
@ -29,10 +29,8 @@
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
|
|
||||||
import edbob
|
import edbob
|
||||||
from edbob.pyramid import grids
|
|
||||||
from edbob.pyramid.forms import AssociationProxyField
|
from edbob.pyramid.forms import AssociationProxyField
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView
|
from edbob.pyramid.views import SearchableAlchemyGridView
|
||||||
from edbob.pyramid.views.crud import Crud
|
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
|
|
||||||
|
@ -40,9 +38,7 @@ import rattail
|
||||||
class EmployeesGrid(SearchableAlchemyGridView):
|
class EmployeesGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Employee
|
mapped_class = rattail.Employee
|
||||||
route_name = 'employees'
|
config_prefix = 'employees'
|
||||||
route_url = '/employees'
|
|
||||||
renderer = '/employees/index.mako'
|
|
||||||
sort = 'first_name'
|
sort = 'first_name'
|
||||||
|
|
||||||
def join_map(self):
|
def join_map(self):
|
||||||
|
@ -55,9 +51,9 @@ class EmployeesGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
return self.make_filter_map(
|
return self.make_filter_map(
|
||||||
first_name=grids.search.filter_ilike(edbob.Person.first_name),
|
first_name=self.filter_ilike(edbob.Person.first_name),
|
||||||
last_name=grids.search.filter_ilike(edbob.Person.last_name),
|
last_name=self.filter_ilike(edbob.Person.last_name),
|
||||||
phone=grids.search.filter_ilike(rattail.EmployeePhoneNumber.number))
|
phone=self.filter_ilike(rattail.EmployeePhoneNumber.number))
|
||||||
|
|
||||||
def filter_config(self):
|
def filter_config(self):
|
||||||
return self.make_filter_config(
|
return self.make_filter_config(
|
||||||
|
@ -69,9 +65,9 @@ class EmployeesGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
def sort_map(self):
|
def sort_map(self):
|
||||||
return self.make_sort_map(
|
return self.make_sort_map(
|
||||||
first_name=grids.util.sorter(edbob.Person.first_name),
|
first_name=self.sorter(edbob.Person.first_name),
|
||||||
last_name=grids.util.sorter(edbob.Person.last_name),
|
last_name=self.sorter(edbob.Person.last_name),
|
||||||
phone=grids.util.sorter(rattail.EmployeePhoneNumber.number))
|
phone=self.sorter(rattail.EmployeePhoneNumber.number))
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
q = self.make_query()
|
q = self.make_query()
|
||||||
|
@ -94,20 +90,9 @@ class EmployeesGrid(SearchableAlchemyGridView):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
class EmployeeCrud(Crud):
|
|
||||||
|
|
||||||
mapped_class = rattail.Employee
|
|
||||||
home_route = 'employees.list'
|
|
||||||
|
|
||||||
def fieldset(self, obj):
|
|
||||||
fs = self.make_fieldset(obj)
|
|
||||||
fs.configure(
|
|
||||||
include=[
|
|
||||||
fs.person,
|
|
||||||
])
|
|
||||||
return fs
|
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
EmployeesGrid.add_route(config)
|
|
||||||
EmployeeCrud.add_routes(config)
|
config.add_route('employees', '/employees')
|
||||||
|
config.add_view(EmployeesGrid, route_name='employees',
|
||||||
|
renderer='/employees/index.mako',
|
||||||
|
permission='employees.list')
|
||||||
|
|
|
@ -32,9 +32,7 @@ from sqlalchemy.orm import joinedload
|
||||||
|
|
||||||
import edbob
|
import edbob
|
||||||
from edbob.pyramid import Session
|
from edbob.pyramid import Session
|
||||||
from edbob.pyramid import grids
|
from edbob.pyramid.views import SearchableAlchemyGridView, CrudView
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView
|
|
||||||
from edbob.pyramid.views.crud import Crud
|
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
import rattail.labels
|
import rattail.labels
|
||||||
|
@ -44,9 +42,7 @@ from rattail.pyramid.forms import UpcFieldRenderer, PriceFieldRenderer
|
||||||
class ProductsGrid(SearchableAlchemyGridView):
|
class ProductsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Product
|
mapped_class = rattail.Product
|
||||||
route_name = 'products'
|
config_prefix = 'products'
|
||||||
route_url = '/products'
|
|
||||||
renderer = '/products/index.mako'
|
|
||||||
sort = 'description'
|
sort = 'description'
|
||||||
clickable = True
|
clickable = True
|
||||||
|
|
||||||
|
@ -72,9 +68,9 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
return self.make_filter_map(
|
return self.make_filter_map(
|
||||||
exact=['upc'],
|
exact=['upc'],
|
||||||
ilike=['description', 'size'],
|
ilike=['description', 'size'],
|
||||||
brand=grids.search.filter_ilike(rattail.Brand.name),
|
brand=self.filter_ilike(rattail.Brand.name),
|
||||||
department=grids.search.filter_ilike(rattail.Department.name),
|
department=self.filter_ilike(rattail.Department.name),
|
||||||
subdepartment=grids.search.filter_ilike(rattail.Subdepartment.name))
|
subdepartment=self.filter_ilike(rattail.Subdepartment.name))
|
||||||
|
|
||||||
def filter_config(self):
|
def filter_config(self):
|
||||||
return self.make_filter_config(
|
return self.make_filter_config(
|
||||||
|
@ -91,11 +87,11 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
def sort_map(self):
|
def sort_map(self):
|
||||||
return self.make_sort_map(
|
return self.make_sort_map(
|
||||||
'upc', 'description', 'size',
|
'upc', 'description', 'size',
|
||||||
brand=grids.util.sorter(rattail.Brand.name),
|
brand=self.sorter(rattail.Brand.name),
|
||||||
department=grids.util.sorter(rattail.Department.name),
|
department=self.sorter(rattail.Department.name),
|
||||||
subdepartment=grids.util.sorter(rattail.Subdepartment.name),
|
subdepartment=self.sorter(rattail.Subdepartment.name),
|
||||||
regular_price=grids.util.sorter(rattail.ProductPrice.price),
|
regular_price=self.sorter(rattail.ProductPrice.price),
|
||||||
current_price=grids.util.sorter(rattail.ProductPrice.price))
|
current_price=self.sorter(rattail.ProductPrice.price))
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
q = self.make_query()
|
q = self.make_query()
|
||||||
|
@ -123,8 +119,7 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
],
|
],
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
|
||||||
g.row_route_name = 'product.read'
|
g.click_route_name = 'product.read'
|
||||||
g.row_route_kwargs = lambda x: {'uuid': x.uuid}
|
|
||||||
|
|
||||||
if edbob.config.getboolean('rattail.labels', 'enabled', default=False):
|
if edbob.config.getboolean('rattail.labels', 'enabled', default=False):
|
||||||
def labels(row):
|
def labels(row):
|
||||||
|
@ -134,13 +129,13 @@ class ProductsGrid(SearchableAlchemyGridView):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
class ProductCrud(Crud):
|
class ProductCrud(CrudView):
|
||||||
|
|
||||||
mapped_class = rattail.Product
|
mapped_class = rattail.Product
|
||||||
home_route = 'products'
|
home_route = 'products'
|
||||||
|
|
||||||
def fieldset(self, obj):
|
def fieldset(self, model):
|
||||||
fs = self.make_fieldset(obj)
|
fs = self.make_fieldset(model)
|
||||||
fs.upc.set(renderer=UpcFieldRenderer)
|
fs.upc.set(renderer=UpcFieldRenderer)
|
||||||
fs.regular_price.set(renderer=PriceFieldRenderer)
|
fs.regular_price.set(renderer=PriceFieldRenderer)
|
||||||
fs.current_price.set(renderer=PriceFieldRenderer)
|
fs.current_price.set(renderer=PriceFieldRenderer)
|
||||||
|
@ -177,11 +172,20 @@ def print_label(request):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
ProductsGrid.add_route(config)
|
|
||||||
ProductCrud.add_routes(config)
|
config.add_route('products', '/products')
|
||||||
|
config.add_view(ProductsGrid, route_name='products',
|
||||||
|
renderer='/products/index.mako',
|
||||||
|
permission='products.list')
|
||||||
|
|
||||||
config.add_route('products.print_label', '/products/label')
|
config.add_route('products.print_label', '/products/label')
|
||||||
config.add_view(print_label, route_name='products.print_label', renderer='json')
|
config.add_view(print_label, route_name='products.print_label',
|
||||||
|
renderer='json')
|
||||||
|
|
||||||
|
config.add_route('product.read', '/products/{uuid}')
|
||||||
|
config.add_view(ProductCrud, attr='read', route_name='product.read',
|
||||||
|
renderer='/products/read.mako',
|
||||||
|
permission='products.read')
|
||||||
|
|
||||||
|
|
||||||
# from sqlalchemy.orm import joinedload
|
# from sqlalchemy.orm import joinedload
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
``rattail.pyramid.views.subdepartments`` -- Subdepartment Views
|
``rattail.pyramid.views.subdepartments`` -- Subdepartment Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView, AlchemyGridView
|
from edbob.pyramid.views import SearchableAlchemyGridView
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
|
|
||||||
|
@ -34,10 +34,7 @@ import rattail
|
||||||
class SubdepartmentsGrid(SearchableAlchemyGridView):
|
class SubdepartmentsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Subdepartment
|
mapped_class = rattail.Subdepartment
|
||||||
route_name = 'subdepartments'
|
config_prefix = 'subdepartments'
|
||||||
route_url = '/subdepartments'
|
|
||||||
renderer = '/subdepartments/index.mako'
|
|
||||||
permission = 'subdepartments.list'
|
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
@ -63,4 +60,8 @@ class SubdepartmentsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
SubdepartmentsGrid.add_route(config)
|
|
||||||
|
config.add_route('subdepartments', '/subdepartments')
|
||||||
|
config.add_view(SubdepartmentsGrid, route_name='subdepartments',
|
||||||
|
renderer='/subdepartments/index.mako',
|
||||||
|
permission='subdepartments.list')
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from edbob.pyramid.views import SearchableAlchemyGridView, AutocompleteView
|
from edbob.pyramid.views import SearchableAlchemyGridView, AutocompleteView
|
||||||
from edbob.pyramid.views.crud import Crud
|
|
||||||
|
|
||||||
import rattail
|
import rattail
|
||||||
|
|
||||||
|
@ -35,10 +34,7 @@ import rattail
|
||||||
class VendorsGrid(SearchableAlchemyGridView):
|
class VendorsGrid(SearchableAlchemyGridView):
|
||||||
|
|
||||||
mapped_class = rattail.Vendor
|
mapped_class = rattail.Vendor
|
||||||
route_name = 'vendors'
|
config_prefix = 'vendors'
|
||||||
route_url = '/vendors'
|
|
||||||
renderer = '/vendors/index.mako'
|
|
||||||
permission = 'vendors.list'
|
|
||||||
sort = 'name'
|
sort = 'name'
|
||||||
|
|
||||||
def filter_map(self):
|
def filter_map(self):
|
||||||
|
@ -66,28 +62,19 @@ class VendorsGrid(SearchableAlchemyGridView):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
class VendorCrud(Crud):
|
class VendorsAutocomplete(AutocompleteView):
|
||||||
|
|
||||||
mapped_class = rattail.Vendor
|
|
||||||
home_route = 'vendors.list'
|
|
||||||
|
|
||||||
def fieldset(self, obj):
|
|
||||||
fs = self.make_fieldset(obj)
|
|
||||||
fs.configure(
|
|
||||||
include=[
|
|
||||||
fs.id,
|
|
||||||
fs.name,
|
|
||||||
])
|
|
||||||
return fs
|
|
||||||
|
|
||||||
|
|
||||||
class VendorAutocomplete(AutocompleteView):
|
|
||||||
|
|
||||||
mapped_class = rattail.Vendor
|
mapped_class = rattail.Vendor
|
||||||
fieldname = 'name'
|
fieldname = 'name'
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
VendorsGrid.add_route(config)
|
|
||||||
VendorCrud.add_routes(config)
|
config.add_route('vendors', '/vendors')
|
||||||
VendorAutocomplete.add_route(config)
|
config.add_view(VendorsGrid, route_name='vendors',
|
||||||
|
renderer='/vendors/index.mako',
|
||||||
|
permission='vendors.list')
|
||||||
|
|
||||||
|
config.add_route('vendors.autocomplete', '/vendors/autocomplete')
|
||||||
|
config.add_view(VendorsAutocomplete, route_name='vendors.autocomplete',
|
||||||
|
renderer='json', permission='vendors.list')
|
||||||
|
|
Loading…
Reference in a new issue