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 changeIdeaTitle(): #changes an idea's title try: print "Attempting title change" session=idea_box.createAll() username="******".lower() title="A stupid Title".lower() newTitle="A great title".lower() if idea_box.changeTitle(username,title,newTitle,session): print "Title Changed" else: print "Title not changed" session.close() except: print "Title Chjange error" raise else: print "title change error free" outputIdea(username.lower(),newTitle.lower())