Add POD image support to product view page.
This commit is contained in:
parent
087342b09c
commit
389bb5dcc6
3 changed files with 40 additions and 1 deletions
|
@ -26,6 +26,8 @@
|
|||
Product Views
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy.orm import joinedload, aliased
|
||||
|
||||
|
@ -48,6 +50,7 @@ from rattail.db.model import (
|
|||
Brand, Vendor, Department, Subdepartment, LabelProfile)
|
||||
from rattail.gpc import GPC
|
||||
from rattail.db.api import get_product_by_upc
|
||||
from rattail.pod import get_image_url, get_image_path
|
||||
|
||||
from ..db import Session
|
||||
from ..forms import GPCFieldRenderer, BrandFieldRenderer, PriceFieldRenderer
|
||||
|
@ -264,6 +267,18 @@ class ProductCrud(CrudView):
|
|||
del fs.current_price
|
||||
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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue