コード例 #1
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)
コード例 #2
0
ファイル: grub.py プロジェクト: vchang2/grub
 def GET(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     editAbout = False
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     recipeID = 0
     if 'recipeID' in post_params:
         recipeID = post_params['recipeID']
     recipe = sqlitedb.getRecipe(recipeID)
     instructions = sqlitedb.getInstructions(recipeID)
     ingredients = sqlitedb.getIngredients(recipeID)
     tags = sqlitedb.getTags(recipeID)
     photos = sqlitedb.getPhotos(recipeID)
     categories = sqlitedb.getCategories(recipeID)
     reviews = sqlitedb.getReviews(recipeID)
     userVotes = {0 : 'na'}
     for review in reviews:
         userVotes[review['ReviewID']] = sqlitedb.userVoted(review['ReviewID'], session.user)
     userHasReviewed = sqlitedb.hasUserReviewed(recipeID, session.user)
     cookbooks = sqlitedb.getCookbooks(session.user)
     userMatchesRecipeAuthor = False
     for result in recipe:
         if session.user == result['UserID']:
             userMatchesRecipeAuthor = True
     return render_template('view_recipe.html', recipe = recipe, recipeID = recipeID, instructions = instructions, ingredients = ingredients, tags = tags, photos = photos, categories = categories, reviews = reviews, cookbooks = cookbooks, currentUser = session.user, userHasReviewed = userHasReviewed, userMatchesRecipeAuthor = userMatchesRecipeAuthor, userVotes = userVotes, editAbout = editAbout)
コード例 #3
0
ファイル: grub.py プロジェクト: 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)
コード例 #4
0
ファイル: grub.py プロジェクト: 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)
コード例 #5
0
 def GET(self):
     if session.user == None:
         return render_template('login.html')
     post_params = web.input()
     editAbout = False
     if 'editAboutMe' in post_params:
         editAbout = True
     if 'newAboutMe' in post_params:
         editAbout = False
         sqlitedb.updateAboutMe(userID, post_params['newAboutMe'])
     recipeID = 0
     if 'recipeID' in post_params:
         recipeID = post_params['recipeID']
     recipe = sqlitedb.getRecipe(recipeID)
     instructions = sqlitedb.getInstructions(recipeID)
     ingredients = sqlitedb.getIngredients(recipeID)
     tags = sqlitedb.getTags(recipeID)
     photos = sqlitedb.getPhotos(recipeID)
     categories = sqlitedb.getCategories(recipeID)
     reviews = sqlitedb.getReviews(recipeID)
     userVotes = {0: 'na'}
     for review in reviews:
         userVotes[review['ReviewID']] = sqlitedb.userVoted(
             review['ReviewID'], session.user)
     userHasReviewed = sqlitedb.hasUserReviewed(recipeID, session.user)
     cookbooks = sqlitedb.getCookbooks(session.user)
     userMatchesRecipeAuthor = False
     for result in recipe:
         if session.user == result['UserID']:
             userMatchesRecipeAuthor = True
     return render_template('view_recipe.html',
                            recipe=recipe,
                            recipeID=recipeID,
                            instructions=instructions,
                            ingredients=ingredients,
                            tags=tags,
                            photos=photos,
                            categories=categories,
                            reviews=reviews,
                            cookbooks=cookbooks,
                            currentUser=session.user,
                            userHasReviewed=userHasReviewed,
                            userMatchesRecipeAuthor=userMatchesRecipeAuthor,
                            userVotes=userVotes,
                            editAbout=editAbout)
コード例 #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)