コード例 #1
0
def planner():
    current_week = get_week(TODAY)
    week_recipes = get_week_recipes(current_week)
    return render_template('pages/planner.html',
                           current_week=current_week,
                           first_week_day=TODAY,
                           week_recipes=week_recipes,
                           title="planner")
コード例 #2
0
def jump_to():
    ''' renders a view of week starting with a date chosen by user'''
    selected_date = request.args.get('jump_to')
    date_list = selected_date.split('-')
    first_week_date = datetime.date(int(date_list[0]), int(date_list[1]),
                                    int(date_list[2]))
    current_week = get_week(first_week_date)
    week_recipes = get_week_recipes(current_week)
    return render_template('pages/planner.html',
                           current_week=current_week,
                           first_week_day=first_week_date,
                           week_recipes=week_recipes,
                           title="planner")
コード例 #3
0
def previous():
    ''' calculates dates for -1 week from last view'''
    first_week_day = request.form.get('first_week_day')
    date_list = first_week_day.split('-')
    date_obj = datetime.date(int(date_list[0]), int(date_list[1]),
                             int(date_list[2]))
    current_week = get_week(date_obj - datetime.timedelta(weeks=1))
    first_week_day = str(current_week[0][0])
    week_recipes = get_week_recipes(current_week)
    return render_template('pages/planner.html',
                           current_week=current_week,
                           first_week_day=first_week_day,
                           week_recipes=week_recipes,
                           title="planner")
コード例 #4
0
def del_from_schedule(recipe_id, date, daytime, first_week_day):
    ''' removes date from dates array in the recipe document '''
    recipes = mongo.db.recipes
    recipes.update({'_id': ObjectId(recipe_id)},
                   {"$pull": {
                       "dates": (date, daytime)
                   }})
    date_list = first_week_day.split('-')
    first_week_date = datetime.date(int(date_list[0]), int(date_list[1]),
                                    int(date_list[2]))
    current_week = get_week(first_week_date)
    week_recipes = get_week_recipes(current_week)
    return render_template('pages/planner.html',
                           current_week=current_week,
                           first_week_day=first_week_date,
                           week_recipes=week_recipes,
                           title="planner")