Exemplo n.º 1
0
 def reviews(self):
     recipes = self.recipes()
     reviews = []
     for recipe in recipes:
         for review in Review.all():
             if recipe == review.recipe:
                 reviews.append(review)
     return reviews
 def reviews(self):
     recipe_list = self.recipes()
     review_list = []
     for item in recipe_list:
         review_list += [
             review for review in Review.all() if review.recipe == item
         ]
     return review_list
 def test_review_class_methods(self):
     self.assertItemsEqual(Review._all, [
         review_1, review_2, review_3, review_4, review_5, review_6,
         review_7, review_8, review_9, review_10
     ])
     self.assertItemsEqual(Review.all(), [
         review_1, review_2, review_3, review_4, review_5, review_6,
         review_7, review_8, review_9, review_10
     ])
 def favorite_recipe(self):
     recipe_list = {
         review.recipe: review.rating
         for review in Review.all() if review.reviewer == self
     }
     favorite = max(recipe_list.values())
     return [
         review for review, rating in recipe_list.items()
         if rating == favorite
     ][0]
Exemplo n.º 5
0
 def bottom_three(cls):
     recipe_dict = {}
     for item in Review.all():
         recipe_dict[item.recipe] = item.recipe.avg_rating()
     sorted_recipe_dict = dict(
         sorted(recipe_dict.items(), key=lambda item: item[1]))
     final_list = []
     for i in range(0, 3):
         final_list.append(list(sorted_recipe_dict.keys())[i])
     return final_list
 def most_active_critic(cls):
     for review in Review.all():
         if not review.reviewer in Guest.reviewer_dict.keys():
             Guest.reviewer_dict[review.reviewer] = [review.rating]
         else:
             Guest.reviewer_dict[review.reviewer].append(review.rating)
     for reviewer in Guest.reviewer_dict:
         Guest.review_count[reviewer] = len(Guest.reviewer_dict[reviewer])
         most_active = max(Guest.review_count.values())
     return [
         reviewer for reviewer in Guest.review_count
         if Guest.review_count[reviewer] == most_active
     ][0]
 def toughest_critic(cls):
     for review in Review.all():
         if not review.reviewer in Guest.reviewer_dict.keys():
             Guest.reviewer_dict[review.reviewer] = [review.rating]
         else:
             Guest.reviewer_dict[review.reviewer].append(review.rating)
     for reviewer in Guest.reviewer_dict:
         Guest.reviewer_average_rating_dict[reviewer] = sum(
             Guest.reviewer_dict[reviewer]) / len(
                 Guest.reviewer_dict[reviewer])
     toughest = min(Guest.reviewer_average_rating_dict.values())
     return [
         reviewer for reviewer in Guest.reviewer_average_rating_dict
         if Guest.reviewer_average_rating_dict[reviewer] == toughest
     ][0]
 def reviews(self):
     recipe_names = [recipe.name for recipe in self.recipes()]
     return [review for review in Review.all() if review.recipe.name in recipe_names]
Exemplo n.º 9
0
 def review_recipe(self, recipe, rating, comment):
     Review(self, recipe, rating, comment)
     return [review for review in Review.all() if review.recipe == recipe]
Exemplo n.º 10
0
 def reviews(self):
     return [review for review in Review.all() if review.reviewer == self]
Exemplo n.º 11
0
 def highest_rated_recipe(self): # highest average
     rating_list = [review.rating for review in Review.all()]
     highest = max(rating_list)
     return [review.recipe for review in Review.all() if review.rating == highest][0]
Exemplo n.º 12
0
 def reviews(self):
     recipe_list = [course.recipe for course in Course.all() if course.dinner_party == self]
     for recipe in recipe_list:
         return [review for review in Review.all() if review.recipe in recipe_list]
 def reviews(self):
     return [review for review in Review.all() if review.guest == self]