Clean up products view imports etc. a bit.
This commit is contained in:
parent
fee00b96a2
commit
ab40685175
|
@ -24,20 +24,18 @@
|
|||
Product Views
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy.orm import joinedload, aliased
|
||||
|
||||
import formalchemy
|
||||
from webhelpers.html.tags import link_to
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
from pyramid.renderers import render_to_response
|
||||
from webhelpers.html import tags
|
||||
|
||||
import rattail.labels
|
||||
from rattail import enum
|
||||
|
@ -72,15 +70,15 @@ class ProductsGrid(SearchableAlchemyGridView):
|
|||
# These aliases enable the grid queries to filter products which may be
|
||||
# purchased from *any* vendor, and yet sort by only the "preferred" vendor
|
||||
# (since that's what shows up in the grid column).
|
||||
ProductCostAny = aliased(ProductCost)
|
||||
VendorAny = aliased(Vendor)
|
||||
ProductCostAny = orm.aliased(ProductCost)
|
||||
VendorAny = orm.aliased(Vendor)
|
||||
|
||||
def join_map(self):
|
||||
|
||||
def join_vendor(q):
|
||||
q = q.outerjoin(
|
||||
ProductCost,
|
||||
and_(
|
||||
sa.and_(
|
||||
ProductCost.product_uuid == Product.uuid,
|
||||
ProductCost.preference == 1,
|
||||
))
|
||||
|
@ -166,12 +164,12 @@ class ProductsGrid(SearchableAlchemyGridView):
|
|||
q = self.make_query()
|
||||
if not self.request.has_perm('products.view_deleted'):
|
||||
q = q.filter(model.Product.deleted == False)
|
||||
q = q.options(joinedload(Product.brand))
|
||||
q = q.options(joinedload(Product.department))
|
||||
q = q.options(joinedload(Product.subdepartment))
|
||||
q = q.options(joinedload(Product.regular_price))
|
||||
q = q.options(joinedload(Product.current_price))
|
||||
q = q.options(joinedload(Product.vendor))
|
||||
q = q.options(orm.joinedload(Product.brand))
|
||||
q = q.options(orm.joinedload(Product.department))
|
||||
q = q.options(orm.joinedload(Product.subdepartment))
|
||||
q = q.options(orm.joinedload(Product.regular_price))
|
||||
q = q.options(orm.joinedload(Product.current_price))
|
||||
q = q.options(orm.joinedload(Product.vendor))
|
||||
return q
|
||||
|
||||
def grid(self):
|
||||
|
@ -214,7 +212,7 @@ class ProductsGrid(SearchableAlchemyGridView):
|
|||
q = Session.query(LabelProfile)
|
||||
if q.count():
|
||||
def labels(row):
|
||||
return link_to("Print", '#', class_='print-label')
|
||||
return tags.link_to("Print", '#', class_='print-label')
|
||||
g.add_column('labels', "Labels", labels)
|
||||
|
||||
return g
|
||||
|
|
Loading…
Reference in a new issue