コード例 #1
0
def recipe_delete(recipe_id):
    """ Delete a recipe by its id"""
    recipe = Recipe.get_recipe_by_id(recipe_id)
    if not recipe:
        raise ErrorException('This recipe does not exist', 500)
    if g.user.id != recipe["user_id"]:
        raise ErrorException('Your authentication is invalid',
                             401)  # Cant delete a recipe that isn't yours
    if Recipe.recipe_delete(recipe_id):
        return jsonify({
            'message': 'Recipe deleted.',
            'statusCode': 200,
            'status': 'success'
        })
コード例 #2
0
def get_recipe(id):
    ''' Given a recipe id, get the details of the corresponding recipe. Schemas can be found in models.py
        (TODO) Add the fields returned by the recipe once they are finalised.
    '''
    return jsonify(Recipe.get_recipe_by_id(id))