def editIdea(title): #sends the idea in title to the same template as add idea #but all appropriate information is filled in if session.get('logged_in'): if request.method=="POST": #change the title, then the body, then the tags, redirect to display the new idea #any errors will flash why, then redirect to display the idea in its current state newTitle=request.form['title'].lower() if idea_box.changeTitle(session['username'],title,newTitle): if idea_box.changeIdea(session['username'],newTitle,request.form['body']): if idea_box.changeTags(session['username'],newTitle,request.form['tags']): flash("Idea change Success!") else: flash("Could not change tags") else: flash("Could not change body") else: flash("Could not change title") results=idea_search.ideaQuery(session['username'],title.lower(),"","").all()[0] return render_template('editIdea.html',idea=results) #display the edited idea results=idea_search.ideaQuery(session['username'],newTitle,"","").all() return render_template('displayResults.html',results=results) else: #we need the edit data, send to edit page results=idea_search.ideaQuery(session['username'],title.lower(),"","").all()[0] return render_template('editIdea.html',idea=results) else: return redirect(url_for('welcome.html'))
def changeBody(): #changes an idea's body try: #create a new use with a randomly generated username print "Attempting body change" session=idea_box.createAll() username="******".lower() title="A great title".lower() if idea_box.changeIdea(username,title,"THIS IS A F*****G BODY",session): print "Body Changed" else: print "Body not changed" session.close() except: print "Body Change error" raise else: print "Body change error free" outputIdea(username.lower(),title.lower())