Tweak some field renderers for sake of product view
This commit is contained in:
parent
ef649d8c96
commit
d40d5e3f6b
|
@ -41,7 +41,7 @@ from .employees import EmployeeFieldRenderer
|
|||
|
||||
from .stores import StoreFieldRenderer
|
||||
from .vendors import VendorFieldRenderer, PurchaseFieldRenderer
|
||||
from .products import (GPCFieldRenderer, DepartmentFieldRenderer, BrandFieldRenderer,
|
||||
ProductFieldRenderer, PriceFieldRenderer, PriceWithExpirationFieldRenderer)
|
||||
from .products import (GPCFieldRenderer, DepartmentFieldRenderer, SubdepartmentFieldRenderer, CategoryFieldRenderer,
|
||||
BrandFieldRenderer, ProductFieldRenderer, PriceFieldRenderer, PriceWithExpirationFieldRenderer)
|
||||
|
||||
from .batch import BatchIDFieldRenderer, HandheldBatchFieldRenderer
|
||||
|
|
|
@ -89,7 +89,7 @@ class DepartmentFieldRenderer(SelectFieldRenderer):
|
|||
if not department:
|
||||
return ''
|
||||
if department.number:
|
||||
text = '{} {}'.format(department.number, department.name)
|
||||
text = '({}) {}'.format(department.number, department.name)
|
||||
else:
|
||||
text = department.name
|
||||
return tags.link_to(text, self.request.route_url('departments.view', uuid=department.uuid))
|
||||
|
@ -97,24 +97,34 @@ class DepartmentFieldRenderer(SelectFieldRenderer):
|
|||
|
||||
class SubdepartmentFieldRenderer(SelectFieldRenderer):
|
||||
"""
|
||||
Shows the subdepartment number as well as the name.
|
||||
Shows a link to the subdepartment.
|
||||
"""
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
sub = self.raw_value
|
||||
if sub:
|
||||
return "{0} - {1}".format(sub.number, sub.name)
|
||||
return ""
|
||||
subdept = self.raw_value
|
||||
if not subdept:
|
||||
return ""
|
||||
if subdept.number:
|
||||
text = "({}) {}".format(subdept.number, subdept.name)
|
||||
else:
|
||||
text = subdept.name
|
||||
return tags.link_to(text, self.request.route_url('subdepartments.view', uuid=subdept.uuid))
|
||||
|
||||
|
||||
class CategoryFieldRenderer(SelectFieldRenderer):
|
||||
"""
|
||||
Shows the category number as well as the name.
|
||||
Shows a link to the category.
|
||||
"""
|
||||
|
||||
def render_readonly(self, **kwargs):
|
||||
cat = self.raw_value
|
||||
if cat:
|
||||
return "{0} - {1}".format(cat.number, cat.name)
|
||||
return ""
|
||||
category = self.raw_value
|
||||
if not category:
|
||||
return ""
|
||||
if category.code:
|
||||
text = "({}) {}".format(category.code, category.name)
|
||||
else:
|
||||
text = category.name
|
||||
return tags.link_to(text, self.request.route_url('categories.view', uuid=category.uuid))
|
||||
|
||||
|
||||
class BrandFieldRenderer(AutocompleteFieldRenderer):
|
||||
|
|
|
@ -28,7 +28,15 @@
|
|||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="render_link_fields(form)"></%def>
|
||||
<%def name="render_main_fields(form)">
|
||||
${render_field_readonly(form.fieldset.upc)}
|
||||
${render_field_readonly(form.fieldset.brand)}
|
||||
${render_field_readonly(form.fieldset.description)}
|
||||
${render_field_readonly(form.fieldset.size)}
|
||||
${render_field_readonly(form.fieldset.unit_size)}
|
||||
${render_field_readonly(form.fieldset.unit_of_measure)}
|
||||
${render_field_readonly(form.fieldset.case_pack)}
|
||||
</%def>
|
||||
|
||||
<%def name="render_organization_fields(form)">
|
||||
${render_field_readonly(form.fieldset.department)}
|
||||
|
@ -68,14 +76,7 @@
|
|||
<h2>Product</h2>
|
||||
<div class="panel-body">
|
||||
<div style="clear: none; float: left;">
|
||||
${render_field_readonly(form.fieldset.upc)}
|
||||
${render_field_readonly(form.fieldset.brand)}
|
||||
${render_field_readonly(form.fieldset.description)}
|
||||
${render_field_readonly(form.fieldset.size)}
|
||||
${render_field_readonly(form.fieldset.unit_size)}
|
||||
${render_field_readonly(form.fieldset.unit_of_measure)}
|
||||
${render_field_readonly(form.fieldset.case_pack)}
|
||||
${self.render_link_fields(form)}
|
||||
${self.render_main_fields(form)}
|
||||
</div>
|
||||
% if image_url:
|
||||
${h.image(image_url, "Product Image", id='product-image', path=image_path, use_pil=False)}
|
||||
|
|
|
@ -266,6 +266,9 @@ class ProductsView(MasterView):
|
|||
def _preconfigure_fieldset(self, fs):
|
||||
fs.upc.set(label="UPC", renderer=forms.renderers.GPCFieldRenderer)
|
||||
fs.brand.set(renderer=forms.renderers.BrandFieldRenderer, options=[])
|
||||
fs.department.set(renderer=forms.renderers.DepartmentFieldRenderer)
|
||||
fs.subdepartment.set(renderer=forms.renderers.SubdepartmentFieldRenderer)
|
||||
fs.category.set(renderer=forms.renderers.CategoryFieldRenderer)
|
||||
fs.unit_of_measure.set(label="Unit of Measure",
|
||||
renderer=forms.renderers.EnumFieldRenderer(self.enum.UNIT_OF_MEASURE))
|
||||
fs.regular_price.set(renderer=forms.renderers.PriceFieldRenderer)
|
||||
|
|
Loading…
Reference in a new issue