From 3fed317805e8b68b880356b24916164b3426e088 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 10 Mar 2015 17:51:12 -0500 Subject: [PATCH] Add UI support for `Product.last_sold` and `current_price_ends` pseudo-field. --- tailbone/templates/products/read.mako | 12 ++++++++++++ tailbone/views/products.py | 12 ++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tailbone/templates/products/read.mako b/tailbone/templates/products/read.mako index 8f9bcae8..1bdac00b 100644 --- a/tailbone/templates/products/read.mako +++ b/tailbone/templates/products/read.mako @@ -33,6 +33,7 @@ <%def name="render_price_fields(form)"> ${render_field_readonly(form.fieldset.regular_price)} ${render_field_readonly(form.fieldset.current_price)} + ${render_field_readonly(form.fieldset.current_price_ends)} ${render_field_readonly(form.fieldset.deposit_link)} ${render_field_readonly(form.fieldset.tax)} @@ -46,6 +47,10 @@ ${render_field_readonly(form.fieldset.deleted)} +<%def name="render_movement_fields(form)"> + ${render_field_readonly(form.fieldset.last_sold)} + +
+
+

Movement

+
+ ${self.render_movement_fields(form)} +
+
+

Vendor Sources

diff --git a/tailbone/views/products.py b/tailbone/views/products.py index 8d46ae28..3f7b80ec 100644 --- a/tailbone/views/products.py +++ b/tailbone/views/products.py @@ -32,8 +32,8 @@ import re 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 @@ -54,7 +54,7 @@ from rattail.pod import get_image_url, get_image_path from tailbone.views import SearchableAlchemyGridView, CrudView from tailbone.views.continuum import VersionView, version_defaults -from tailbone.forms import EnumFieldRenderer +from tailbone.forms import EnumFieldRenderer, DateTimeFieldRenderer from tailbone.db import Session from tailbone.forms import GPCFieldRenderer, BrandFieldRenderer, PriceFieldRenderer from tailbone.progress import SessionProgress @@ -249,6 +249,12 @@ class ProductCrud(CrudView): fs.unit_of_measure.set(renderer=EnumFieldRenderer(enum.UNIT_OF_MEASURE)) fs.regular_price.set(renderer=PriceFieldRenderer) fs.current_price.set(renderer=PriceFieldRenderer) + + fs.append(formalchemy.Field('current_price_ends')) + fs.current_price_ends.set(value=lambda p: p.current_price.ends if p.current_price else None) + fs.current_price_ends.set(renderer=DateTimeFieldRenderer(self.request.rattail_config)) + + fs.last_sold.set(renderer=DateTimeFieldRenderer(self.request.rattail_config)) fs.configure( include=[ fs.upc.label("UPC"), @@ -266,6 +272,7 @@ class ProductCrud(CrudView): fs.report_code, fs.regular_price, fs.current_price, + fs.current_price_ends, fs.deposit_link, fs.tax, fs.organic, @@ -273,6 +280,7 @@ class ProductCrud(CrudView): fs.special_order, fs.not_for_sale, fs.deleted, + fs.last_sold, ]) if not self.readonly: del fs.regular_price