Exemple #1
0
def updateSp(request):
    today = utils.getToday()
    todayD = dateutil.parser.parse(today).date()
    allDishes = json.loads(request.body)
    cnt = 0
    for x in allDishes:
        rs = Dish.objects.filter(pid=x["id"], date__range=(todayD, todayD))
        if rs:
            continue
        d0 = Dish()
        if rs:
            d0.date = rs[0].date
        d0.pid = x["id"]
        d0.name = x["name"]
        d0.booth = x["booth"]
        d0.ingredient = x["ingredient"]
        if "<Simple Wamen>" in x["name"]:
            d0.energy = 320
        else:
            d0.energy = x["energy"]
        d0.price = x["price"]
        d0.mealTime = x["mealTime"]
        d0.floor = x["floor"]
        d0.like = 0
        d0.dislike = 0
        d0.save()
        cnt += 1
    return HttpResponse("INFO(SP): updated %d pictures" % cnt)
Exemple #2
0
def updateSp(request):
    today = utils.getToday()
    todayD = dateutil.parser.parse(today).date()
    allDishes = json.loads(request.body)
    cnt = 0
    for x in allDishes:
        rs = Dish.objects.filter(pid=x["id"], date__range=(todayD, todayD))
        if rs:
            continue
        d0 = Dish()
        if rs:
            d0.date = rs[0].date
        d0.pid = x["id"]
        d0.name = x["name"]
        d0.booth = x["booth"]
        d0.ingredient = x["ingredient"]
        if "<Simple Wamen>" in x["name"]:
            d0.energy = 320
        else:
            d0.energy = x["energy"]
        d0.price = x["price"]
        d0.mealTime = x["mealTime"]
        d0.floor = x["floor"]
        d0.like = 0
        d0.dislike = 0
        d0.save()
        cnt += 1
    return HttpResponse("INFO(SP): updated %d pictures" % cnt)
Exemple #3
0
def test_data(client):
    pizza = Dish(name='pizza', price=10)
    pizza.ingredient = [
        Ingredient(dish_id=pizza.id, name='tomato', allergen=''),
        Ingredient(dish_id=pizza.id, name='cheese', allergen='milk'),
        Ingredient(dish_id=pizza.id, name='flour', allergen='wheat'),
    ]
    pizza.insert()

    salad = Dish(name='salad', price=5)
    salad.ingredient = [
        Ingredient(dish_id=salad.id, name='potato', allergen=''),
        Ingredient(dish_id=salad.id, name='nuts', allergen='peanut'),
        Ingredient(dish_id=salad.id, name='kale', allergen=''),
    ]
    salad.insert()

    icecream = Dish(name='icecream', price=5)
    icecream.ingredient = [
        Ingredient(dish_id=icecream.id, name='cream', allergen='milk'),
    ]
    icecream.insert()