Add POD image support to product view page.
This commit is contained in:
parent
087342b09c
commit
389bb5dcc6
3
setup.py
3
setup.py
|
@ -78,6 +78,9 @@ requires = [
|
||||||
'waitress', # 0.8.1
|
'waitress', # 0.8.1
|
||||||
'WebHelpers', # 1.3
|
'WebHelpers', # 1.3
|
||||||
'zope.sqlalchemy', # 0.7
|
'zope.sqlalchemy', # 0.7
|
||||||
|
|
||||||
|
# This is used to obtain POD image dimensions.
|
||||||
|
'PIL', # 1.1.7
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
<%inherit file="/products/crud.mako" />
|
<%inherit file="/products/crud.mako" />
|
||||||
|
|
||||||
${parent.body()}
|
<%def name="head_tags()">
|
||||||
|
${parent.head_tags()}
|
||||||
|
<style type="text/css">
|
||||||
|
#product-image {
|
||||||
|
float: left;
|
||||||
|
margin-left: 250px;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
<div class="form-wrapper">
|
||||||
|
<ul class="context-menu">
|
||||||
|
${self.context_menu_items()}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
${form.render()|n}
|
||||||
|
|
||||||
|
% if image:
|
||||||
|
${h.image(image_url, u"Product Image", id='product-image', path=image_path, use_pil=True)}
|
||||||
|
% endif
|
||||||
|
</div>
|
||||||
|
|
||||||
<% product = form.fieldset.model %>
|
<% product = form.fieldset.model %>
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
Product Views
|
Product Views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy.orm import joinedload, aliased
|
from sqlalchemy.orm import joinedload, aliased
|
||||||
|
|
||||||
|
@ -48,6 +50,7 @@ from rattail.db.model import (
|
||||||
Brand, Vendor, Department, Subdepartment, LabelProfile)
|
Brand, Vendor, Department, Subdepartment, LabelProfile)
|
||||||
from rattail.gpc import GPC
|
from rattail.gpc import GPC
|
||||||
from rattail.db.api import get_product_by_upc
|
from rattail.db.api import get_product_by_upc
|
||||||
|
from rattail.pod import get_image_url, get_image_path
|
||||||
|
|
||||||
from ..db import Session
|
from ..db import Session
|
||||||
from ..forms import GPCFieldRenderer, BrandFieldRenderer, PriceFieldRenderer
|
from ..forms import GPCFieldRenderer, BrandFieldRenderer, PriceFieldRenderer
|
||||||
|
@ -264,6 +267,18 @@ class ProductCrud(CrudView):
|
||||||
del fs.current_price
|
del fs.current_price
|
||||||
return fs
|
return fs
|
||||||
|
|
||||||
|
def template_kwargs(self, form):
|
||||||
|
kwargs = {'image': False}
|
||||||
|
product = form.fieldset.model
|
||||||
|
if product.upc:
|
||||||
|
kwargs['image_url'] = get_image_url(
|
||||||
|
self.request.rattail_config, product.upc)
|
||||||
|
kwargs['image_path'] = get_image_path(
|
||||||
|
self.request.rattail_config, product.upc)
|
||||||
|
if os.path.exists(kwargs['image_path']):
|
||||||
|
kwargs['image'] = True
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
def products_search(request):
|
def products_search(request):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue