本文整理汇总了Python中helper.Helper.to_dictionary方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.to_dictionary方法的具体用法?Python Helper.to_dictionary怎么用?Python Helper.to_dictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.Helper
的用法示例。
在下文中一共展示了Helper.to_dictionary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_dictionary
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import to_dictionary [as 别名]
def to_dictionary( self, record ):
d = Helper.to_dictionary( self, record )
total_reviews, review_avg, reviews_by_rating = review_stats( record.reviews )
d["total_reviews"] = total_reviews
d["review_avg"] = review_avg
d["reviews_by_rating"] = reviews_by_rating
units = 0
normal_price = 0
discounted_price = 0
date = None
for r in record.inventory:
if r.units > 0 and not date or date and r.date > date:
date = r.date
normal_price = r.normal_price
discounted_price = r.discounted_price
units += r.units
d["units"] = units
d["normal_price"] = normal_price
d["discounted_price"] = discounted_price
return d