Example #1
0
def lazyload():
    search_text = session.get("search_text")
    search_type = session.get("search_type")
    offset = int(request.args.get("offset").encode("utf-8"))
    if offset == 0:
        return
    if search_type == "Title":
        query_list = query.get_pubs(search_text, "title", offset)
    elif search_type == "Author":
        auth_list = (model.session.query(model.Author)
                    .filter(model.Author.last_name.ilike("%" + search_text + "%"))
                    .all())
        if auth_list != None:
            auth_id_list = [auth.id for auth in auth_list]
        else:
            auth_id_list = []
        auth_pubs_list = [query.get_auth_publications(auth_id) for auth_id in auth_id_list]

        query_list = []
        for auth_pubs in auth_pubs_list:
            for auth_pub in auth_pubs:
                query_list.append(auth_pub)
    elif search_type == "Keyword":
        query_list = query.get_pubs(search_text, "full_desc", offset)
    return json.dumps(query_list)
Example #2
0
def results():
    search_text = session.get("search_text")
    search_type = session.get("search_type")

    if search_type == "Title":
        offset = 0
        query_list = query.get_pubs(search_text, "title", offset)
        query_count = query.get_pubs_count(search_text, "title")

    elif search_type == "Author":
        auth_list = (model.session.query(model.Author)
                    .filter(model.Author.last_name.ilike("%" + search_text + "%"))
                    .all())

        auth_id_list = [auth.id for auth in auth_list]
        auth_pubs_list = [query.get_auth_publications(auth_id) for auth_id in auth_id_list]

        query_list = []
        for auth_pubs in auth_pubs_list:
            for auth_pub in auth_pubs:
                query_list.append(auth_pub)

        query_count = len(query_list)

    elif search_type == "Keyword":
        offset = 0
        query_list = query.get_pubs(search_text, "full_desc", offset)
        query_count = query.get_pubs_count(search_text, "full_desc")

    else:
        query_list = []
        query_count = 0

    return render_template("results.html", 
                            search_text = search_text,
                            search_type = search_type,
                            length = len(query_list),
                            results = query_list,
                            count = query_count)