Esempio n. 1
0
 def get(self):
     user = User.get_by_id(self.session.get('user_id'))
     print self.session.get('user_id')
     print user.shopping_list
     print type(user.shopping_list)
     save_cache = Save_cache.get_by_id(DEFAULT_Save_Cache_NAME)
     if not save_cache:
         save_cache = Save_cache(id=DEFAULT_Save_Cache_NAME)
     shopping_dict = []
     for item in user.shopping_list:
         item_dict = {'todoText':item, 'done':False}
         shopping_dict.append(item_dict)
     tmp_recipes_list = []
     for recipe_id in user.tmp_recipes:
         recipe = Recipe.get_by_id(long(recipe_id))
         recipe_dict = {'photo':'http://placehold.it/700x400',
                        'name':recipe.name,
                        'tags':recipe.tags,
                        'id':str(recipe.key.id()),
                        }
         if len(recipe.photos)>0:
             recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
         tmp_recipes_list.append(recipe_dict)
     template = JINJA_ENVIRONMENT.get_template('template/shopping_page.html')
     template_values = {
         'shopping_dict':json.dumps(shopping_dict),
         'tmp_recipes':tmp_recipes_list,
         'keywords':json.dumps(save_cache.save_cache),
     }
     self.response.write(template.render(template_values))
    def post(self):
        user = User.get_by_id(self.request.get('user_id'))

        shoppingList = []
        if self.request.get("DeleteItem")!="":
            DeleteItem = self.request.get("DeleteItem")
            delete_item_list = DeleteItem.split(',')
            for i in xrange(len(user.shopping_list)):
                if str(i) not in delete_item_list:
                    shoppingList.append(user.shopping_list[i])

        for recipe_id in user.tmp_recipes:
                recipe = Recipe.get_by_id(long(recipe_id))
                isInRecipe = False
                for ingredient in recipe.ingredients:
                    if ingredient in shoppingList:
                        isInRecipe = True
                if not isInRecipe:
                    user.tmp_recipes.remove(recipe_id)


        user.shopping_list = shoppingList
        user.put()
        time.sleep(0.5)

        self.redirect('/shoppingpage')
Esempio n. 3
0
    def get(self):
        recipe_id = self.request.get('recipe_id')
        recipe = Recipe.get_by_id(long(recipe_id))
        save_cache = Save_cache.get_by_id(DEFAULT_Save_Cache_NAME)
        if not save_cache:
            save_cache = Save_cache(id=DEFAULT_Save_Cache_NAME)
        photo_urls = []
        for i in xrange(len(recipe.photos)):
            photo_urls.append(images.get_serving_url(recipe.photos[0].blob_key))
        user = User.get_by_id(self.session.get('user_id'))

        template = JINJA_ENVIRONMENT.get_template('template/edit_page.html')
        template_values = {
            'recipe_id':recipe_id,
            'recipe_name':recipe.name,
            'photo_urls':photo_urls,
            'author':user.user_name,
            'description':recipe.description,
            'ingredients':recipe.ingredients,
            'directions':recipe.directions,
            'estimate_time':recipe.estimate_time.strftime('%H:%M'),
            'portion':recipe.portion,
            'tags':json.dumps(recipe.tags),
            'keywords':json.dumps(save_cache.save_cache),
        }
        self.response.write(template.render(template_values))
Esempio n. 4
0
 def post(self):
     recipe_id = self.request.get('recipe_id')
     recipe = Recipe.get_by_id(long(recipe_id))
     if self.request.get('comment')!="":
         user = User.get_by_id(self.session.get('user_id'))
         comment = Comment(author=user.user_id,comment_text=self.request.get('comment'))
         recipe.comments.append(comment)
         recipe.put()
         time.sleep(1)
     self.redirect('viewpage?recipe_id='+str(recipe_id))
    def post(self):
        user = User.get_by_id(self.request.get('user_id'))

        if self.request.get("newItem")!="":
            newItem = self.request.get("newItem")
            user.shopping_list.append(newItem)
            user.put()
            time.sleep(0.5)

        self.redirect('/shoppingpage')
Esempio n. 6
0
    def get(self):
        user_id = self.session.get('user_id')
        print user_id
        print 'ooooooooooooo'
        save_cache = Save_cache.get_by_id(DEFAULT_Save_Cache_NAME)
        if not save_cache:
            save_cache = Save_cache(id=DEFAULT_Save_Cache_NAME)
        user = User.get_by_id(user_id)
        my_recipes_list = []
        recipe_query = Recipe.query(Recipe.author == user_id)
        my_recipes = recipe_query.fetch()
        for recipe in my_recipes:
            print recipe
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            my_recipes_list.append(recipe_dict)

        favorite_recipes_list = []
        for recipe_id in user.favorite_recipes:
            recipe = Recipe.get_by_id(long(recipe_id))
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            favorite_recipes_list.append(recipe_dict)
        wish_recipes_list = []
        for recipe_id in user.wish_recipes:
            recipe = Recipe.get_by_id(long(recipe_id))
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            wish_recipes_list.append(recipe_dict)
        template = JINJA_ENVIRONMENT.get_template('template/recipebox_page.html')
        template_values = {
            'my_recipes':my_recipes_list,
            'favorite_recipes':favorite_recipes_list,
            'wish_recipes':wish_recipes_list,
            'keywords':json.dumps(save_cache.save_cache),
        }
        self.response.write(template.render(template_values))
Esempio n. 7
0
 def post(self):
     recipe_authorID = self.request.get('recipe_authorID')
     recipe_id = self.request.get('recipe_id')
     FromAndroid = self.request.get('FromAndroid')
     if int(FromAndroid)==0:
         recipe = Recipe.get_by_id(long(recipe_id))
         if self.request.get('comment')!="":
             user = User.get_by_id(self.session.get('user_id'))
             comment = Comment(author=user.user_id,comment_text=self.request.get('comment'))
             recipe.comments.append(comment)
             recipe.put()
             time.sleep(1)
     else:
         history_query = History.query(History.recipe_id ==recipe_id, History.recipe_authorID==recipe_authorID)
         recipe_query_all= history_query.fetch()
         if self.request.get('comment')!="":
             user = User.get_by_id(self.session.get('user_id'))
             comment = Comment(author=user.user_id,comment_text=self.request.get('comment'))
             recipe_query_all[0].comments.append(comment)
             recipe_query_all[0].put()
             time.sleep(1)
     self.redirect('/timeline')
    def get(self):
        user = User.get_by_id(self.request.get('user_id'))

        shopping_dict = []
        for item in user.shopping_list:
            item_dict = {'todoText':item, 'done':False}
            shopping_dict.append(item_dict)

        json_dict = {"item":[]}

        if len(user.shopping_list) != 0:
            for item in user.shopping_list:
                json_dict['item'].append(item)
        jsonObj = json.dumps(json_dict, sort_keys=True,indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Esempio n. 9
0
 def get(self):
     recipe_id = self.request.get('recipe_id')
     type = self.request.get('type')
     value = self.request.get('value')
     user = User.get_by_id(self.session.get('user_id'))
     if type=="favorite":
         if value == "true":
             user.favorite_recipes.append(recipe_id)
         else:
             user.favorite_recipes.remove(recipe_id)
     elif type=="wish":
         if value == "true":
             user.wish_recipes.append(recipe_id)
         else:
             user.wish_recipes.remove(recipe_id)
     user.put()
     time.sleep(0.5)
     self.redirect('viewpage?recipe_id='+str(recipe_id))
Esempio n. 10
0
 def post(self):
     user = User.get_by_id(self.session.get('user_id'))
     if self.request.get("newItem")!="":
         newItem = self.request.get("newItem")
         user.shopping_list.append(newItem)
         user.put()
         time.sleep(0.5)
     elif self.request.get("shoppingList")!="":
         shoppingList = [ item["todoText"] for item in json.loads(self.request.get("shoppingList"))]
         user.shopping_list = shoppingList
         for recipe_id in user.tmp_recipes:
             recipe = Recipe.get_by_id(long(recipe_id))
             isInRecipe = False
             for ingredient in recipe.ingredients:
                 if ingredient in user.shopping_list:
                     isInRecipe = True
             if not isInRecipe:
                 user.tmp_recipes.remove(recipe_id)
         user.put()
         time.sleep(0.5)
     self.redirect('/shoppingpage')
Esempio n. 11
0
    def post(self):
        upload = self.get_uploads()[0]
        recipe_id = self.request.get('recipe_id')
        recipe = Recipe.get_by_id(long(recipe_id))
        # # user_id = self.session.get('user_id')
        author_comments = self.request.get('author_comments')
        user_id = self.request.get('user_id')
        user = User.get_by_id(user_id)

        #img = images.resize(img, 200, 200)
        # if len(upload) >0:
        #     recipe.photos.append(Photo(
        #     blob_key = upload[0].key(),
        #     filename= upload[0].filename,
        # ))
        recipe.put()

        history = History()
        history.recipe_name = recipe.name
        history.author_comments = author_comments
        history.FromAndroid = True
        history.recipe_id = str(recipe.key.id())
        history.tags = recipe.tags
        history.recipe_author= user.user_name
        history.recipe_description= recipe.description
        history.recipe_authorID = user_id

        history.photos.append(Photo(
            blob_key = upload.key(),
            filename= "hi",
        ))
        # if len(upload) >0:
        #     history.photos.append(Photo(
        #         # blob_key = upload[0].key(),
        #         # filename= upload[0].filename,
        #         blob_key = upload.key(),
        #         filename= "hi",
        #     ))
        history.put()
        time.sleep(1)
Esempio n. 12
0
 def get(self):
     recipe_id = self.request.get('recipe_id')
     ingredient_idx = int(self.request.get('ingredient_idx'))-1
     if self.request.get('add') == 'true':
         isAdd = True
     else:
         isAdd = False
     user_id = self.session.get('user_id')
     recipe = Recipe.get_by_id(long(recipe_id))
     user = User.get_by_id(self.session.get('user_id'))
     if ingredient_idx < 0:
         if isAdd:
             if recipe_id not in user.tmp_recipes:
                 user.tmp_recipes.append(recipe_id)
             for ingredient in recipe.ingredients:
                 if ingredient not in user.shopping_list:
                     user.shopping_list.append(ingredient)
         else:
             for ingredient in recipe.ingredients:
                 user.shopping_list.remove(ingredient)
             if recipe_id in user.tmp_recipes:
                 user.tmp_recipes.remove(recipe_id)
     else:
         if isAdd:
             if recipe_id not in user.tmp_recipes:
                 user.tmp_recipes.append(recipe_id)
             if recipe.ingredients[ingredient_idx] not in user.shopping_list:
                 user.shopping_list.append(recipe.ingredients[ingredient_idx])
         else:
             user.shopping_list.remove(recipe.ingredients[ingredient_idx])
             isInRecipe = False
             for ingredient in recipe.ingredients:
                 if ingredient in user.shopping_list:
                     isInRecipe = True
             if not isInRecipe:
                 user.tmp_recipes.remove(recipe_id)
     user.put()
     time.sleep(0.5)
     self.redirect('viewpage?recipe_id='+str(recipe_id))
Esempio n. 13
0
    def post(self):
        upload = self.get_uploads('cover_image')
        name = self.request.get('recipe_name')
        author = self.request.get('user_id')
        recipe_query = Recipe.query(Recipe.name == name,Recipe.author == author)
        recipes = recipe_query.fetch(1)
        if len(recipes) >0:
            self.error(409)
            self.redirect('/error?error=1')
        else:
            recipe = Recipe()

            recipe.name = name
            if self.request.get('estimated_time') != "":
                tmp = time.strptime(self.request.get('estimated_time'),"%H:%M")
                recipe.estimate_time = datetime.time(hour=tmp.tm_hour,minute=tmp.tm_min)
            else:
                recipe.estimate_time =datetime.time(hour=0,minute=0)
            recipe.portion = int(self.request.get('portions'))
            recipe.description = self.request.get('description')

            ingredient_number = int(self.request.get('ingredient_number'))
            for i in xrange(ingredient_number):
                if self.request.get('ingredient'+str(i+1))!="":
                    recipe.ingredients.append(self.request.get('ingredient'+str(i+1)))

            direction_number = int(self.request.get('direction_number'))
            for i in xrange(direction_number):
                if self.request.get('direction'+str(i+1))!="":
                    recipe.directions.append(self.request.get('direction'+str(i+1)))
            if self.request.get('tag[]')!="":
                recipe.tags = json.loads(self.request.get('tag[]'))

            recipe.favorite_count = 0
            recipe.view_count = 0
            if len(upload) >0:
                recipe.photos.append(Photo(
                    blob_key = upload[0].key(),
                    filename= upload[0].filename,
                ))
            recipe.author = author

            recipe.put()
            history = History()
            history.recipe_name = name
            history.FromAndroid = False
            history.recipe_id = str(recipe.key.id())
            history.tags = json.loads(self.request.get('tag[]'))
            history.recipe_author=User.get_by_id(author).user_name
            history.recipe_description= self.request.get('description')
            history.recipe_authorID = author
            if len(upload) >0:
                history.photos.append(Photo(
                    blob_key = upload[0].key(),
                    filename= upload[0].filename,
                ))
            history.put()
            print history

            time.sleep(1)
            self.redirect('/viewpage?recipe_id='+str(recipe.key.id()))
Esempio n. 14
0
    def get(self):
        recipe_id = self.request.get('recipe_id')
        recipe = Recipe.get_by_id(long(recipe_id))

        photo_urls = []
        for i in xrange(len(recipe.photos)):
            photo_urls.append(images.get_serving_url(recipe.photos[0].blob_key))
        author = User.get_by_id(recipe.author)
        ingredients_list = []
        # user = User.get_by_id(self.session.get('user_id'))
        # shopping_list = user.shopping_list
        # isAllInList = True
        for ingredient in recipe.ingredients:
            ingredients_list.append(ingredient)

        # isAuthor = False
        # if user.user_id == author.user_id:
        #     isAuthor = True
        # isFavorite = False
        # if recipe_id in user.favorite_recipes:
        #     isFavorite = True
        # isWish = False
        # if recipe_id in user.wish_recipes:
        #     isWish = True
        comments_list = []
        for comment in recipe.comments:
            author2 = User.get_by_id(comment.author)
            time_str = comment.time.strftime("%B %d, %Y at %H:%M:%S")
            comment_dict = {
                'author':author2.user_name,
                'author_profile':author2.photo,
                'comment_text':comment.comment_text,
                'time': time_str,
            }
            comments_list.append(comment_dict)

        same_list = []
        recipe_name = Recipe.query(Recipe.name==recipe.name)
        for recipe2 in recipe_name:
            if User.get_by_id(recipe2.author).user_name is not author.user_name:
                same_dict = {
                    'author': User.get_by_id(recipe2.author).user_name,
                    'recipe_id': recipe2.key.id(),
                }
                same_list.append(same_dict)
        print author.user_name
        # template = JINJA_ENVIRONMENT.get_template('template/view_page.html')
        # template_values = {
        #     'recipe_id':recipe_id,
        #     'recipe_name':recipe.name,
        #     'photo_urls':photo_urls,
        #     'author':author.user_name,
        #     'ingredients':ingredients_list,
        #     'directions':recipe.directions,
        #     'estimate_time':recipe.estimate_time,
        #     'portion':recipe.portion,
        #     'tags':recipe.tags,
        #     'isAllInList':isAllInList,
        #     'isFavorite':isFavorite,
        #     'isWish':isWish,
        #     'isAuthor':isAuthor,
        #     'comments_list':comments_list,
        #     'same_list':same_list,
        # }
        # self.response.write(template.render(template_values))

        json_dict = {"recipe_id":[],"recipe_name":[],"photo_urls":[],"author":[],"ingredients":[],"directions":[],"estimate_time":[],"portion":[],"tags":[],"isAllInList":[],"isFavorite":[],"isWish":[],"isAuthor":[],"comments_list":[],"same_list":[]}
        json_dict['recipe_id'] = recipe_id
        json_dict['recipe_name'] = recipe.name
        json_dict['photo_urls'] = photo_urls[0]
        json_dict['author'] = author.user_name
        json_dict['ingredients'] = ingredients_list
        json_dict['directions'] =recipe.directions
        json_dict['estimate_time']=recipe.estimate_time.strftime("%H:%M")
        json_dict['portion'] = recipe.portion
        json_dict['tags']= recipe.tags
        # json_dict['isAllInList']= isAllInList
        # json_dict['isFavorite'] =isFavorite
        # json_dict['isWish'] = isWish
        # json_dict['isAuthor'] = isAuthor
        json_dict['comments_list'] = comments_list
        json_dict['same_list'] = same_list
        jsonObj = json.dumps(json_dict, sort_keys=True,indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Esempio n. 15
0
 def post(self):
     user_name = self.request.get('user_name')
     user_id = self.request.get('user_id')
     user_friends = json.loads(self.request.get('user_friends'))
     photo = self.request.get('photo')
     print photo
     self.session['user_name'] = user_name
     self.session['user_id'] = user_id
     user = User.get_by_id(user_id)
     if not user:
         user = User(id=user_id)
         user.user_id = user_id
         user.user_name = user_name
         user.friends = [friend['id'] for friend in user_friends]
         user.photo = photo
         user.put()
         time.sleep(1)
     else:
         user.friends = [friend['id'] for friend in user_friends]
         user.photo = photo
         user.put()
         time.sleep(1)
     self.redirect('/createpage')
Esempio n. 16
0
    def get(self):
        user_id = self.request.get('user_id')
        list_type = self.request.get('list_type')
        list_type_int = int(list_type)

        user = User.get_by_id(user_id)
        my_recipes_list = []
        recipe_query = Recipe.query(Recipe.author == user_id)
        my_recipes = recipe_query.fetch()
        for recipe in my_recipes:
            print recipe
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            my_recipes_list.append(recipe_dict)

        favorite_recipes_list = []
        for recipe_id in user.favorite_recipes:
            recipe = Recipe.get_by_id(long(recipe_id))
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            favorite_recipes_list.append(recipe_dict)
        wish_recipes_list = []

        for recipe_id in user.wish_recipes:
            recipe = Recipe.get_by_id(long(recipe_id))
            recipe_dict = {'photo':'http://placehold.it/700x400',
                           'name':recipe.name,
                           'tags':recipe.tags,
                           'id':str(recipe.key.id()),
                           }
            if len(recipe.photos)>0:
                recipe_dict['photo'] = images.get_serving_url(recipe.photos[0].blob_key)
            wish_recipes_list.append(recipe_dict)

        recipes_list = []
        if list_type_int==1:
            recipes_list = my_recipes_list
        elif list_type_int ==2:
            recipes_list = favorite_recipes_list
        else:
            recipes_list = wish_recipes_list


        json_dict = {"photo":[],"name":[],"tags":[],"id":[]}

        if len(recipes_list) != 0:
            for tmp in recipes_list:
                json_dict['photo'].append(tmp['photo'])
                json_dict['name'].append(tmp['name'])
                json_dict['tags'].append(tmp['tags'])
                json_dict['id'].append(tmp['id'])

        jsonObj = json.dumps(json_dict, sort_keys=True,indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Esempio n. 17
0
    def get(self):
        recipe_id = self.request.get('recipe_id')
        print "-------------------"
        recipe = Recipe.get_by_id(long(recipe_id))

        recipe_query = History.query(History.recipe_authorID==self.session.get('user_id'))
        recipe_query_test = recipe_query.fetch()
        print recipe_query_test
        print 'yoyoyoyoyo'

        save_cache = Save_cache.get_by_id(DEFAULT_Save_Cache_NAME)
        if not save_cache:
            save_cache = Save_cache(id=DEFAULT_Save_Cache_NAME)
        photo_urls = []
        for i in xrange(len(recipe.photos)):
            photo_urls.append(images.get_serving_url(recipe.photos[i].blob_key))
        author = User.get_by_id(recipe.author)
        ingredients_list = []
        user = User.get_by_id(self.session.get('user_id'))
        shopping_list = user.shopping_list
        isAllInList = True
        for ingredient in recipe.ingredients:
            if ingredient in shopping_list:
                ingredients_list.append((ingredient,True))
            else:
                ingredients_list.append((ingredient,False))
                isAllInList = False
        isAuthor = False
        if user.user_id == author.user_id:
            isAuthor = True
        isFavorite = False
        if recipe_id in user.favorite_recipes:
            isFavorite = True
        isWish = False
        if recipe_id in user.wish_recipes:
            isWish = True
        comments_list = []
        for comment in recipe.comments:
            author2 = User.get_by_id(comment.author)
            time_str = comment.time.strftime("%B %d, %Y at %H:%M:%S")
            comment_dict = {
                'author':author2.user_name,
                'author_profile':author2.photo,
                'comment_text':comment.comment_text,
                'time': time_str,
            }
            comments_list.append(comment_dict)

        same_list = []
        recipe_name = Recipe.query(Recipe.name==recipe.name)
        for recipe2 in recipe_name:
            if User.get_by_id(recipe2.author).user_name is not author.user_name:
                same_dict = {
                    'author': User.get_by_id(recipe2.author).user_name,
                    'recipe_id': recipe2.key.id(),
                }
                same_list.append(same_dict)
        print author.user_name
        template = JINJA_ENVIRONMENT.get_template('template/view_page.html')
        template_values = {
            'recipe_id':recipe_id,
            'recipe_name':recipe.name,
            'keywords':json.dumps(save_cache.save_cache),
            'photo_urls':photo_urls,
            'author':author.user_name,
            'ingredients':ingredients_list,
            'directions':recipe.directions,
            'estimate_time':recipe.estimate_time,
            'portion':recipe.portion,
            'tags':recipe.tags,
            'isAllInList':isAllInList,
            'isFavorite':isFavorite,
            'isWish':isWish,
            'isAuthor':isAuthor,
            'comments_list':comments_list,
            'same_list':same_list,
            'same_list_len':len(same_list),
        }
        self.response.write(template.render(template_values))
Esempio n. 18
0
    def get(self):

        # recipe_query = History.query(History.recipe_authorID==self.session.get('user_id'))
        recipe_query = History.query()
        recipe_query_all_tmp = recipe_query.fetch()
        recipe_query_all= sorted(recipe_query_all_tmp, key=lambda contract: (contract.create_time.strftime("%Y-%m-%d %H:%M:%S")), reverse=True)
        print recipe_query_all

        print 'yoyoyoyoyo'

        save_cache = Save_cache.get_by_id(DEFAULT_Save_Cache_NAME)
        if not save_cache:
            save_cache = Save_cache(id=DEFAULT_Save_Cache_NAME)



        history_list = []
        for tmp in recipe_query_all:
            if tmp.FromAndroid == False:
                FromAndroid =0
            else:
                FromAndroid =1

            if len(tmp.tags)==0:
                tmp.tags.append('Delicious')
                tmp.tags.append('YUMMY')
            print tmp.recipe_id
            # avatar = images.resize(tmp.photos[0], 32, 32)
            print type(tmp.create_time.strftime)

            if not tmp.recipe_id:
                # tmp.recipe_id = '5302669702856704'
                tmp.recipe_id = '5629499534213120'
            if not tmp.author_comments:
                tmp.author_comments = 'its good'

            recipe = Recipe.get_by_id(long(tmp.recipe_id))

            comments_list = []
            if tmp.FromAndroid == False:
                for comment in recipe.comments:
                    author2 = User.get_by_id(comment.author)
                    time_str = comment.time.strftime("%B %d, %Y at %H:%M:%S")
                    comment_dict = {
                        'author':author2.user_name,
                        'author_profile':author2.photo,
                        'comment_text':comment.comment_text,
                        'time': time_str,
                    }
                    comments_list.append(comment_dict)
            else:
                for comment in tmp.comments:
                    author2 = User.get_by_id(comment.author)
                    time_str = comment.time.strftime("%B %d, %Y at %H:%M:%S")
                    comment_dict = {
                        'author':author2.user_name,
                        'author_profile':author2.photo,
                        'comment_text':comment.comment_text,
                        'time': time_str,
                    }
                    comments_list.append(comment_dict)

            recipe_dict = {'recipe_author': tmp.recipe_author,
                           'recipe_name':  tmp.recipe_name,
                           'comments': tmp.comments,
                           'comments_author': tmp.comments_author,
                           'author_comments': tmp.author_comments,
                           'comments_list': comments_list,
                           'recipe_authorID':tmp.recipe_authorID,
                           'tags': tmp.tags,
                           'id': tmp.recipe_id,
                           'FromAndroid': FromAndroid,
                           'create_time':  tmp.create_time.strftime("%Y-%m-%d %H:%M:%S"),
                           'user_photo': User.get_by_id(tmp.recipe_authorID).photo,
                           'photo': images.get_serving_url(tmp.photos[0].blob_key),
                           'recipe_description':  tmp.recipe_description,
                           }
            history_list.append(recipe_dict)


        template = JINJA_ENVIRONMENT.get_template('template/timeline.html')
        template_values = {
            'history_list':history_list,
            'keywords':json.dumps(save_cache.save_cache),
        }
        self.response.write(template.render(template_values))