def phrase_latest(): phrases = Phrase.get_all() return render_template("phrase-latest.html", title="Latest Phrases", phrases=phrases)
def index(): phrase = Phrase.get_last() phrases = Phrase.get_all() my_phrases = None return render_template( "phrase-list.html", title="Search Phrases", phrases=phrases, my_phrases=my_phrases, phrase=phrase, )
def phrase_list(): term = request.args.get("term", "") regex = r"[^\w\.\s\-\,]" term = re.sub(regex, "", term.lower().strip()) phrase = Phrase.get_last() if term and "," in term: if current_user.is_authenticated: Comparison.add_comparison(term=term, user=current_user) else: Comparison.add_comparison(term=term) elif term: if current_user.is_anonymous: phrase = Phrase.lookup(term) else: phrase = Phrase.lookup(term, user=current_user) if phrase == None: flash("Something went wrong") # elif phrase.search_count == 1: # flash('New search phrase! ') # else: # flash('Searched ' + str(phrase.search_count) + ' times!') phrases = Phrase.get_all(limit=500) if current_user.is_anonymous: my_phrases = None else: my_phrases = User.get_by_email(current_user.email).phrases return render_template( "phrase-list.html", title="Search Phrases", phrases=phrases, my_phrases=my_phrases, phrase=phrase, )