예제 #1
0
파일: server.py 프로젝트: jturn130/eatable
def get_search_results(userid):
    """Run search query and return results."""

    search_query = request.args.get("searchQuery")

    if search_query != '':
        ##returns list of tuples
        ##index[0] = recipe_id
        ##index[1] = recipe_title
        ##index[2] = rank
        search_recipes = Recipe.run_search_query(userid, search_query)

    else:
        #gets all user recipes if the search query field is blank
        search_recipes = Recipe.get_user_recipe_list(userid)

    #creates dictionary from search results
    #key = recipeid
    #value = {dictionary of recipe title and userid}
    recipes_list = []

    for recipe in search_recipes:
        recipe = list(recipe)
        recipes_list.append(recipe)

    return json.dumps(recipes_list)
예제 #2
0
def get_search_results(userid):
    """Run search query and return results."""

    search_query = request.args.get("searchQuery")

    if search_query != '':
        ##returns list of tuples
        ##index[0] = recipe_id
        ##index[1] = recipe_title
        ##index[2] = rank
        search_recipes = Recipe.run_search_query(userid, search_query)

    else:
        #gets all user recipes if the search query field is blank
        search_recipes = Recipe.get_user_recipe_list(userid)

    #creates dictionary from search results
    #key = recipeid
    #value = {dictionary of recipe title and userid}
    recipes_list = []

    for recipe in search_recipes:
        recipe = list(recipe)
        recipes_list.append(recipe)

    return json.dumps(recipes_list)
예제 #3
0
def display_recipe_list(userid):
    """Display a list of recipes for a given user."""

    user_recipes = Recipe.get_user_recipe_list(userid)

    return render_template("recipe_list.html",
                           userid=userid,
                           user_recipes=user_recipes)
예제 #4
0
파일: server.py 프로젝트: jturn130/eatable
    def get(self, userid):
        """Get a list of user recipes. Returns JSON as {recipe_id: recipe_title}."""

        user_recipes = Recipe.get_user_recipe_list(userid)

        recipes_dict = {}

        for r in user_recipes:
            recipes_dict[r[0]] = r[1]
        return recipes_dict
예제 #5
0
    def get(self, userid):
        """Get a list of user recipes. Returns JSON as {recipe_id: recipe_title}."""

        user_recipes = Recipe.get_user_recipe_list(userid)

        recipes_dict = {}

        for r in user_recipes:
            recipes_dict[r[0]] = r[1]
        return recipes_dict
예제 #6
0
파일: server.py 프로젝트: jturn130/eatable
def get_suggestions():
    """Get user data for typeahead suggestions."""

    userid = session['User']

    #### Hashtag Data ####
    hashtag_data = Hashtag.get_hashtags_by_user(userid)
    hashtag_list = [h[0] for h in hashtag_data]

    #### Recipe Data ####
    recipe_data = Recipe.get_user_recipe_list(userid)
    recipe_list = [r[1] for r in recipe_data]

    #### Ingredient Data ####
    ingredient_data = Ingredient.get_ingredients_by_user(userid)
    # convert to set then back to list to remove duplicates
    ingredient_list = list(set([i[0] for i in ingredient_data]))

    #### Combined Data ####
    data_list = hashtag_list + recipe_list + ingredient_list

    return jsonify({"userdata": data_list})
예제 #7
0
def get_suggestions():
    """Get user data for typeahead suggestions."""

    userid = session['User']

    #### Hashtag Data ####
    hashtag_data = Hashtag.get_hashtags_by_user(userid)
    hashtag_list = [h[0] for h in hashtag_data]

    #### Recipe Data ####
    recipe_data = Recipe.get_user_recipe_list(userid)
    recipe_list = [r[1] for r in recipe_data]

    #### Ingredient Data ####
    ingredient_data = Ingredient.get_ingredients_by_user(userid)
    # convert to set then back to list to remove duplicates
    ingredient_list = list(set([i[0] for i in ingredient_data]))

    #### Combined Data ####
    data_list = hashtag_list + recipe_list + ingredient_list

    return jsonify({"userdata": data_list})
예제 #8
0
파일: server.py 프로젝트: jturn130/eatable
def display_recipe_list(userid):
    """Display a list of recipes for a given user."""

    user_recipes = Recipe.get_user_recipe_list(userid)

    return render_template("recipe_list.html", userid=userid, user_recipes=user_recipes)