def _format_product_to_show(self, p, only_show_first_photo=False): p.country = Country.get_display(p.country) p.brand = Brand.get_display(p.brand) p.region = Region.get_display(p.region) p.grape_sort = GrapeSort.get_display(p.grape_sort) p.sort = WineSort.get_display(p.sort) p.wine_level = WineLevel.get_display(p.wine_level) dp = m2d(p) if only_show_first_photo: # just show first photo img = p.photos.where(ProductPhoto.seq_num == 1)[0] dp["img_url"] = img.hash_value + "." + img.photo_type else: img = p.photos dp["img_url"] = [i.hash_value + "." + i.photo_type for i in img] scenes = p.scenes labels = p.labels dp["scenes"] = [Scene.get_display(i.scene) for i in scenes] dp["labels"] = [ProductLabel.get_display(i.label) for i in labels] return dp
def get_grape_sort_list(self): grape_sort_list = GrapeSort.select() return grape_sort_list