Esempio n. 1
0
def api_next_meals():
    upcoming_meals = session.query(Meal).filter(Meal.date >= datetime.datetime.now().date()).order_by(Meal.date).all()

    return jsonify(meals=[
        {
            "date": m.date.isoformat(),
            "type": m.mealtype,
            "name_de": m.name,
            "name_en": m.name_en
        }
        for m in upcoming_meals
    ])
Esempio n. 2
0
def api_meals_on(date):
    date = datetime.datetime.strptime(date, "%Y-%m-%d")
    meals = session.query(Meal).filter(Meal.date == date).all()

    return jsonify(meals=[
        {
            "date": m.date.isoformat(),
            "type": m.mealtype,
            "name_de": m.name,
            "name_en": m.name_en
        }
        for m in meals
    ])
Esempio n. 3
0
def meals_on(date):
    date = datetime.datetime.strptime(date, "%Y-%m-%d")
    meals = session.query(Meal).filter(Meal.date == date).order_by(Meal.mealtype).all()

    meals_grouped = group_meals(meals)
    return render_template("index.html", meals=sorted(list(meals_grouped.values()), key=lambda d: d['date']))
Esempio n. 4
0
def home():
    upcoming_meals = session.query(Meal).filter(Meal.date >= datetime.datetime.now().date()).order_by(Meal.mealtype).order_by(Meal.date).all()
    meals_grouped = group_meals(upcoming_meals)

    return render_template("index.html", meals=sorted(list(meals_grouped.values()), key=lambda d: d['date']))