Example #1
0
def search():
    form = SearchForm()
    posts = Post.query.all()
    sortedPosts = []

    # if request.method == 'POST':
    if form.validate_on_submit():
        q = form.query.data
        x = q.split()
        f = False

        for post in posts:
            f = False
            y = post.title.split()
            for i in x:
                for j in y:
                    if (i.lower() == j.lower()):
                        sortedPosts.append(post)
                        f = True
                        break
                if (f):
                    break

        return render_template('search.html', form=form, posts=sortedPosts)
    return render_template('search.html', form=form, posts=sortedPosts)
Example #2
0
def home():
	blist = None
	posts = Post.query.order_by(Post.upvotes.desc()).all()
	form = SearchForm()
	form2 = UpvoteForm()
	form3 = BookmarkForm()
	if current_user.is_authenticated:
		blist = current_user.bookmarks 
	if form.validate_on_submit():
		x = form.select.data
		y = form.search.data
		return redirect(url_for('searchresult', ref = x, arg = y))
	return render_template('home.html', posts=posts, form = form, form2 = form2, form3 = form3, blist = blist)
Example #3
0
def search():
    form = SearchForm()
    if form.validate_on_submit():
        # posts = Post.query.filter() order_by(Post.date_posted.desc())
        page = request.args.get('page', 1, type=int)
        if (form.univ.data and form.city.data):
            post = Post.query.filter_by(city=form.city.data).order_by(
                Post.costpp).paginate(page=page, per_page=5)
        elif (form.univ.data):
            post = Post.query.filter_by(univ=form.univ.data).order_by(
                Post.date_posted.desc(),
                Post.costpp.desc()).paginate(page=page, per_page=5)
        else:
            post = Post.query.filter_by(city=form.city.data).order_by(
                Post.date_posted.desc()).paginate(page=page, per_page=5)
        flash('Here are your stories!!', 'success')
        return render_template('search_results.html', posts=post)
    return render_template('search.html',
                           title='Search Stories',
                           form=form,
                           legend='Search Stories')
Example #4
0
def search():
	sear = []
	form = SearchForm()
	l = len(Check.query.all())
	
	if form.validate_on_submit():

		s = form.search.data

		for i in range (0,l):
		    g = Check.query.all()[i]
		    if(s in g.vehicle_no or s in g.license):
		   		if g not in sear:
		   			sear.append(g)

		k = len(sear)
		sear  =Remove(sear)
		if k == 0:
			flash (f'0 Query results !', 'warning')
			return redirect(url_for('search'))
		
		return render_template('search.html',s = sear ,length = k,data = s)	
			
	return render_template('search_now.html',title = 'Search', form = form )
Example #5
0
def search():
    form = SearchForm()
    return render_template("search.html", form=form)
Example #6
0
def home():
    page = request.args.get('page', 1, type=int)
    posts = Post.query.order_by(Post.date_posted.desc()).paginate(page=page,
                                                                  per_page=5)
    form = SearchForm(request.form)
    return render_template('home.html', posts=posts, form=form)
Example #7
0
def search():
    listLength = 0
    outputList = []
    inputData = []
    name = 'none'
    query = Product_Information.query.first()
    test = Product.query.all()
    if len(test) < 1:
        instantiateItem()
    form = SearchForm()
    if form.validate_on_submit():
        category = form.category.data
        searchInt = form.searchCritereaNumber.data
        serachText = form.searchCritereaText.data
        inputData = [[category, searchInt]]  #, serachText)]

        print(inputData[0][0])
        if inputData[0][0] == 'Product':
            name = Product.query.get(searchInt).product_name
            price = Product.query.get(searchInt).price
            ID = Product.query.get(searchInt).Product_ID
            quantity = Product.query.get(searchInt).quantity
            outputList = [['name', name], ['price', price], ['ID', ID],
                          ['quantity', quantity]]
            listLength = len(outputList)
        elif inputData[0][0] == 'Product_Information':
            IndividualID = Product_Information.query.get(
                searchInt).Individual_ID
            expirationDate = Product_Information.query.get(
                searchInt).expiration_date
            product_weight = Product_Information.query.get(
                searchInt).product_weight
            outputList = [['Individual ID', IndividualID],
                          ['Expiration Date', expirationDate],
                          ['Product Weight', product_weight]]
            listLength = len(outputList)
        elif inputData[0][0] == 'Part_Of_Relationship':
            IndividualID = Part_Of_Relationship.query.get(
                searchInt).IndividualID
            ProductID = Part_Of_Relationship.query.get(searchInt).Product_ID
            outputList = [['Individual ID', IndividualID],
                          ['Product ID', ProductID]]
            listLength = len(outputList)
        elif inputData[0][0] == 'Employees':
            EmployeeID = Employees.query.get(searchInt).Employee_ID
            Name = Employees.query.get(searchInt).name
            Title = Employees.query.get(searchInt).title
            Salary = Employees.query.get(searchInt).salary
            JoinDate = Employees.query.get(searchInt).join_date
            outputList = [['Employee ID', EmployeeID], ['Name', Name],
                          ['Title', Title], ['Salary', Salary],
                          ['Join Date', JoinDate]]
            listLength = len(outputList)

        # query = text("SELECT * FROM" + inputData[0][0] + "where Product_ID is " + str(searchInt))

    return render_template('search.html',
                           title='New Search',
                           form=form,
                           legend='New Post',
                           outputList=outputList,
                           listLength=listLength)