Beispiel #1
0
def customer_get_meals(reuqest):
		meals = MealSerializer(
			Meal.objects.filter(restaurant_id = restaurant_id).order_by("-id"),
			many = True,
			context = {"request": request}
			)
		return JsonResponse({"meals": meals})
Beispiel #2
0
def customer_get_meals(request, restaurant_id):
    meals = MealSerializer(Meal.objects.filter(
        restaurant_id=restaurant_id).order_by("category__meal"),
                           many=True,
                           context={
                               "request": request
                           }).data

    return JsonResponse({"meals": meals})
Beispiel #3
0
def customer_get_itemsInCategories(request, restaurant_id, category_id):
    itemsInCategory = MealSerializer(Meal.objects.filter(
        restaurant_id=restaurant_id, category=category_id).order_by("name"),
                                     many=True,
                                     context={
                                         "request": request
                                     }).data

    return JsonResponse({"itemsInCategory": itemsInCategory})
Beispiel #4
0
def customer_get_meals(request, restaurant_id):
    meals = MealSerializer(
        Meal.objects.filter(restaurant_id=restaurant_id).order_by("-id"),
        many=True,
        context={
            'request': request
        }  # for get the absolute url of the image
    ).data
    return JsonResponse({'meals': meals})
Beispiel #5
0
def get_meal_modifiers(request, restaurant_id):
    meals = Meal.objects.filter(restaurant_id=restaurant_id)
    modifiers = defaultdict(list)
    for meal in meals:
        meal_modifiers = meal.modifier.all()
        for meal_modifier in meal_modifiers:
            modifiers[meal_modifier].append(meal)
    meal_extras = dict()
    for modifier in modifiers.keys():
        meal_extras[modifier.name] = MealSerializer(modifiers[modifier], many=True, context={'request': request}).data

    return JsonResponse({"modifiers": meal_extras})