Ejemplo n.º 1
0
 def GET(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     cookbookID = None
     cookbookRecipes = None
     cookbookInfo = None
     recipes = []
     all_photos = None
     all_recipes = None
     cookbookInfo = None
     recipe_photos = []
     if 'cookbookID' in post_params:
         cookbookID = post_params['cookbookID']
         cookbookRecipes = sqlitedb.getCookbooks_recipes(cookbookID)
         for recipe in cookbookRecipes:
             recipes.append(recipe['RecipeID'])
         if len(recipes) > 0:
             all_photos = sqlitedb.getRecipePhotos(recipes)
             all_recipes = sqlitedb.getRecipes(recipes)
             for r in all_photos:
                 recipe_photos.append(r['Photo'])
         cookbookInfo = sqlitedb.getCookbookInfo(cookbookID)
     return render_template('view_cookbook.html',
                            cookbookID=cookbookID,
                            cookbookInfo=cookbookInfo,
                            cookbookRecipes=cookbookRecipes,
                            all_photos=all_photos,
                            all_recipes=all_recipes,
                            currentUser=session.user,
                            recipe_photos=recipe_photos)
Ejemplo n.º 2
0
 def POST(self):
     post_params = web.input()
     cookbookID = None
     currentUser = session.user
     editAbout = False
     viewingOwnProfile = False
     recipe_photos = []
     recipes = []
     if 'userID' in post_params:
         userID = post_params['userID']
         if userID == session.user:
             viewingOwnProfile = True
     elif session.user:
         userID = session.user
         viewingOwnProfile = True
     else:
         return render_template('login.html')
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     if 'deleteCookbook' in post_params:
         sqlitedb.deleteCookbook(post_params['deleteCookbook'])
     if 'cookbook' in post_params:
         cookbookID = sqlitedb.assignCookbookID()
         sqlitedb.addCookbook(cookbookID, session.user,
                              post_params['cookbook'])
     if 'deleteRecipe' in post_params:
         recipeID = post_params['deleteRecipe']
         sqlitedb.deleteRecipe(recipeID)
         currentUser = session.user
     if 'userID' in post_params:
         userID = post_params['userID']
         userRecipes = sqlitedb.getUserRecipes(userID)
         for recipe in userRecipes:
             recipes.append(recipe['RecipeID'])
         if len(recipes) > 0:
             all_photos = sqlitedb.getRecipePhotos(recipes)
             for r in all_photos:
                 recipe_photos.append(r['Photo'])
         userAboutMe = sqlitedb.getAboutMe(userID)
         userFollowers = sqlitedb.getFollowers(userID)
         userFollowing = sqlitedb.getFollowing(userID)
         userCookbooks = sqlitedb.getCookbooks(userID)
     if 'unfollowing' in post_params:
         sqlitedb.unfollow(session.user, post_params['unfollowing'])
     if 'addFollower' in post_params:
         sqlitedb.addFollower(post_params['addFollower'], session.user)
     return render_template('view_user.html',
                            userID=userID,
                            userRecipes=userRecipes,
                            userAboutMe=userAboutMe,
                            userFollowers=userFollowers,
                            userFollowing=userFollowing,
                            userCookbooks=userCookbooks,
                            viewingOwnProfile=viewingOwnProfile,
                            currentUser=currentUser,
                            editAbout=editAbout,
                            recipe_photos=recipe_photos)
Ejemplo n.º 3
0
Archivo: grub.py Proyecto: vchang2/grub
 def POST(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     cookbookID = None
     cookbookRecipes = None
     cookbookInfo = None
     recipes = []
     recipe_photos = []
     all_photos = None
     all_recipes = None 
     cookbookInfo = None
     recipeID = None
     if 'recipeID' in post_params:
         recipeID = post_params['recipeID']
         cookbookID = post_params['cookbookID']
         sqlitedb.removeRecipeFromCookbook(cookbookID, recipeID)
     if 'cookbookID' in post_params:
         cookbookID = post_params['cookbookID']
         cookbookRecipes = sqlitedb.getCookbooks_recipes(cookbookID)
         for recipe in cookbookRecipes:
             recipes.append(recipe['RecipeID'])
         if len(recipes) > 0:
             all_photos = sqlitedb.getRecipePhotos(recipes)
             all_recipes = sqlitedb.getRecipes(recipes)
             for r in all_photos:
                 recipe_photos.append(r['Photo'])
         cookbookInfo = sqlitedb.getCookbookInfo(cookbookID)
     return render_template('view_cookbook.html', cookbookID = cookbookID, cookbookInfo = cookbookInfo, cookbookRecipes = cookbookRecipes, all_photos = all_photos, all_recipes = all_recipes, currentUser = session.user, recipe_photos = recipe_photos)
Ejemplo n.º 4
0
Archivo: grub.py Proyecto: vchang2/grub
 def GET(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     userID = None
     userRecipes = None
     userAboutMe = None
     userFollowers = None
     userFollowing = None
     userCookbooks = None
     viewingOwnProfile = False
     editAbout = False
     follower = False
     recipes = []
     recipe_photos = []
     currentUser = session.user
     if 'userID' in post_params:
         userID = post_params['userID']
         if userID == session.user:
             viewingOwnProfile = True
     elif session.user:
         userID = session.user
         viewingOwnProfile = True
     else:
         return render_template('login.html')
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     following = sqlitedb.getFollowing(currentUser)
     for r in following:
         print r['UserID']
         if r['UserID'] == userID:
             follower = True
     userRecipes = sqlitedb.getUserRecipes(userID)
     for recipe in userRecipes:
         recipes.append(recipe['RecipeID'])
     if len(recipes) > 0:
         all_photos = sqlitedb.getRecipePhotos(recipes)
         for r in all_photos:
             recipe_photos.append(r['Photo'])
     userAboutMe = sqlitedb.getAboutMe(userID)
     userFollowers = sqlitedb.getFollowers(userID)
     userFollowing = sqlitedb.getFollowing(userID)
     userCookbooks = sqlitedb.getCookbooks(userID)
     if 'unfollowing' in post_params:
         sqlitedb.unfollow(session.user, post_params['unfollowing'])
     print recipe_photos
     return render_template('view_user.html', userID = userID, userRecipes = userRecipes, userAboutMe = userAboutMe, userFollowers = userFollowers, userFollowing = userFollowing, userCookbooks = userCookbooks, viewingOwnProfile = viewingOwnProfile, currentUser = currentUser, editAbout = editAbout, follower = follower, recipe_photos = recipe_photos)
Ejemplo n.º 5
0
Archivo: grub.py Proyecto: vchang2/grub
 def POST(self):
     post_params = web.input()
     cookbookID = None
     currentUser = session.user
     editAbout = False
     viewingOwnProfile = False
     recipe_photos = []
     recipes = []
     if 'userID' in post_params:
         userID = post_params['userID']
         if userID == session.user:
             viewingOwnProfile = True
     elif session.user:
         userID = session.user
         viewingOwnProfile = True
     else:
         return render_template('login.html')
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     if 'deleteCookbook' in post_params:
         sqlitedb.deleteCookbook(post_params['deleteCookbook'])
     if 'cookbook' in post_params:
         cookbookID = sqlitedb.assignCookbookID()
         sqlitedb.addCookbook(cookbookID, session.user, post_params['cookbook'])
     if 'deleteRecipe' in post_params:
         recipeID = post_params['deleteRecipe']
         sqlitedb.deleteRecipe(recipeID)
         currentUser = session.user
     if 'userID' in post_params:
         userID = post_params['userID']
         userRecipes = sqlitedb.getUserRecipes(userID)
         for recipe in userRecipes:
             recipes.append(recipe['RecipeID'])
         if len(recipes) > 0:
             all_photos = sqlitedb.getRecipePhotos(recipes)
             for r in all_photos:
                 recipe_photos.append(r['Photo'])
         userAboutMe = sqlitedb.getAboutMe(userID)
         userFollowers = sqlitedb.getFollowers(userID)
         userFollowing = sqlitedb.getFollowing(userID)
         userCookbooks = sqlitedb.getCookbooks(userID)
     if 'unfollowing' in post_params:
         sqlitedb.unfollow(session.user, post_params['unfollowing'])
     if 'addFollower' in post_params:
         sqlitedb.addFollower(post_params['addFollower'], session.user)
     return render_template('view_user.html', userID = userID, userRecipes = userRecipes, userAboutMe = userAboutMe, userFollowers = userFollowers, userFollowing = userFollowing, userCookbooks = userCookbooks, viewingOwnProfile=viewingOwnProfile, currentUser = currentUser, editAbout = editAbout, recipe_photos = recipe_photos)
Ejemplo n.º 6
0
 def GET(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     userID = None
     userRecipes = None
     userAboutMe = None
     userFollowers = None
     userFollowing = None
     userCookbooks = None
     viewingOwnProfile = False
     editAbout = False
     follower = False
     recipes = []
     recipe_photos = []
     currentUser = session.user
     if 'userID' in post_params:
         userID = post_params['userID']
         if userID == session.user:
             viewingOwnProfile = True
     elif session.user:
         userID = session.user
         viewingOwnProfile = True
     else:
         return render_template('login.html')
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     following = sqlitedb.getFollowing(currentUser)
     for r in following:
         print r['UserID']
         if r['UserID'] == userID:
             follower = True
     userRecipes = sqlitedb.getUserRecipes(userID)
     for recipe in userRecipes:
         recipes.append(recipe['RecipeID'])
     if len(recipes) > 0:
         all_photos = sqlitedb.getRecipePhotos(recipes)
         for r in all_photos:
             recipe_photos.append(r['Photo'])
     userAboutMe = sqlitedb.getAboutMe(userID)
     userFollowers = sqlitedb.getFollowers(userID)
     userFollowing = sqlitedb.getFollowing(userID)
     userCookbooks = sqlitedb.getCookbooks(userID)
     if 'unfollowing' in post_params:
         sqlitedb.unfollow(session.user, post_params['unfollowing'])
     print recipe_photos
     return render_template('view_user.html',
                            userID=userID,
                            userRecipes=userRecipes,
                            userAboutMe=userAboutMe,
                            userFollowers=userFollowers,
                            userFollowing=userFollowing,
                            userCookbooks=userCookbooks,
                            viewingOwnProfile=viewingOwnProfile,
                            currentUser=currentUser,
                            editAbout=editAbout,
                            follower=follower,
                            recipe_photos=recipe_photos)