Esempio n. 1
0
def my_recipes_insert():
    database = Database(filename)
    user_id = session['user_id']
    if request.method == 'POST':
        content = request.form['content']
        if content == '':
            return redirect(url_for('my_recipes'))
        content = Unicode_to_UTF8(content)
        content = content.split(' ')
        dish_name = content[0]
        content.remove(dish_name)
        components = content
        database.insertMyRecipeEntry(user_id, dish_name, components)
    return redirect(url_for('my_recipes'))
Esempio n. 2
0
def admin_my_recipes_insert():
    if not 'user_id' in session:
        return redirect(url_for('login_name'))
    if session['user_id'] != 0:
        return "You don't have the access!"
    user_id = 0
    if request.method == 'POST':
        user_id = request.form['current_user_id']
        database = Database(filename)
        content = request.form['content']
        if content == '':
            return redirect(url_for('admin_my_recipes', user_id=user_id))
        content = Unicode_to_UTF8(content)
        content = content.split(' ')
        dish_name = content[0]
        content.remove(dish_name)
        components = content
        database.insertMyRecipeEntry(user_id, dish_name, components)
    return redirect(url_for('admin_my_recipes', user_id=user_id))