def search_results(query): #tokenize terms = re.split('\s', query) #generate regular expression from tokens x = "|".join(map(str, terms)) regx = re.compile(x, re.IGNORECASE) #query database pins = Pin.objects(Q(title=regx) | Q(dscrp=regx)) if current_user != None: pins = Pin.objects(Q(title=regx) | Q(dscrp=regx)) valid_pins = getValidBrowserPins(pins, current_user) return render_template("index.html", pins=valid_pins, upform=UploadForm())
def search(): #get form input query = request.form.get('q') #tokenize terms = re.split('\s', query) #generate regular expression from tokens x = "|".join(map(str, terms)) regx = re.compile(x, re.IGNORECASE) #query database pins = Pin.objects(Q(title=regx) | Q(dscrp=regx)) return render_template("index.html", pins=pins, upform=UploadForm())
def favorites(uname): user = User.objects.get(uname=uname) pins = Pin.objects(favs__contains=user.to_dbref()) valid_pins = getValidBrowserPins(pins, current_user) return render_template('profilepins.html', pins=valid_pins, upform=UploadForm(), user=user)
def profile_pins(uname): user = User.objects.get(uname=uname) pins = Pin.objects(pinner=user.to_dbref()).order_by('-date') valid_pins = getValidBrowserPins(pins, current_user) return render_template('profilepins.html', pins=valid_pins, upform=UploadForm(), user=user)
def favorites(): pins = Pin.objects(favs__contains=current_user.to_dbref()) return render_template("profilepins.html", pins=pins, upform=UploadForm())
def profilepins(): pins = Pin.objects(pinner=current_user.to_dbref()).order_by("-date") return render_template("profilepins.html", pins=pins, upform=UploadForm())
def favorites(uname): user = User.objects.get(uname=uname) pins = Pin.objects(favs__contains=user.to_dbref()) return render_template('profilepins.html', pins=pins, upform=UploadForm(), user=user)
def profilepins(uname): user = User.objects.get(uname=uname) pins = Pin.objects(pinner=user.to_dbref()).order_by('-date') return render_template('profilepins.html', pins=pins, upform=UploadForm(), user=user)