def addIdea(): #checks if user is logged in, if title is unique #if so, creates idea, then displays it #else flashes error if session.get('logged_in'):#need to verify logged in if request.method=='POST': if idea_box.uniqueTitle(session['username'],request.form['title'].lower()): #checks passed, create the idea idea_box.createIdea(session['username'],request.form['title'].lower(),request.form['body'],request.form['tags']) flash("New Idea Added!") results=idea_search.ideaQuery(session['username'],request.form['title'],"","").all() return render_template('displayResults.html',results=results) #display errors and redirect accordingly else: flash('Title already exists') else: return redirect(url_for('welcome')) return render_template('addIdea.html')
def newIdea(): #create a new idea for a user with no existing ideas try: #add an idea to a user with no existing ideas, if one does not exist, create a new user print "Attempting First Idea Addition" username="******" title="A stupid Title" #find a user with no ideas session=idea_box.createAll() #the test user has no ideas, we will add a new one if idea_box.createIdea(username.lower(),title.lower(),"BODY","tag1,tag2",session): print "Idea Created" else: print "IDea not created" session.close() except: print "Idea Creation Failed" raise else: print "Idea Creation Successful" outputIdea(username.lower(),title.lower())