當前位置: 首頁>>代碼示例>>Python>>正文


Python User.get_by_filtering方法代碼示例

本文整理匯總了Python中src.models.user.User.get_by_filtering方法的典型用法代碼示例。如果您正苦於以下問題:Python User.get_by_filtering方法的具體用法?Python User.get_by_filtering怎麽用?Python User.get_by_filtering使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在src.models.user.User的用法示例。


在下文中一共展示了User.get_by_filtering方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: export_users

# 需要導入模塊: from src.models.user import User [as 別名]
# 或者: from src.models.user.User import get_by_filtering [as 別名]
def export_users():
    country = request.form['country']
    query_builder = {}
    if country != "None" and country != "":
        query_builder.update({"country": country})
    university = request.form['university']
    if university != "None" and university != "":
        query_builder.update({"university": university})
    college = request.form['college']
    if college != "None" and college != "":
        query_builder.update({"school": college})
    subject = request.form['course']
    if subject != "None" and subject != "":
        query_builder.update({"subject": subject})
    level = request.form['level']
    if level != "None":
        query_builder.update({"level": level})
    year = request.form['yearofstudy']
    if year != "None":
        query_builder.update({"year": year})

    action = request.form['action']
    if action != "":
        action_points = int(action)
        if action_points != "":
            action_operator = request.form['action-operator']
            if action_operator == ">":
                query_builder.update({"points.action": {"$gt": action_points}})
            elif action_operator == "<":
                query_builder.update({"points.action": {"$lt": action_points}})
            elif action_operator == "=":
                query_builder.update({"points.action": action_points})

    networking = request.form['networking']
    if networking != "":
        networking_points = int(networking)
        if networking_points != "":
            networking_operator = request.form['networking-operator']
            if networking_operator == ">":
                query_builder.update({"points.networking": {"$gt": networking_points}})
            elif networking_operator == "<":
                query_builder.update({"points.networking": {"$lt": networking_points}})
            elif networking_operator == "=":
                query_builder.update({"points.networking": networking_points})

    practice = request.form['practice']
    if practice != "":
        practice_points = int(request.form['practice'])
        if practice_points != "":
            practice_operator = request.form['practice-operator']
            if practice_operator == ">":
                query_builder.update({"points.practice": {"$gt": practice_points}})
            elif practice_operator == "<":
                query_builder.update({"points.practice": {"$lt": practice_points}})
            elif practice_operator == "=":
                query_builder.update({"points.practice": practice_points})

    project = request.form['project']
    if project != "":
        project_points = int(request.form['project'])
        if project_points != "":
            project_operator = request.form['project-operator']
            if project_operator == ">":
                query_builder.update({"points.project": {"$gt": project_points}})
            elif project_operator == "<":
                query_builder.update({"points.project": {"$lt": project_points}})
            elif project_operator == "=":
                query_builder.update({"points.project": project_points})

    theory = request.form['theory']
    if theory != "":
        theory_points = int(request.form['theory'])
        if theory_points != "":
            theory_operator = request.form['theory-operator']
            if theory_operator == ">":
                query_builder.update({"points.theory": {"$gt": theory_points}})
            elif theory_operator == "<":
                query_builder.update({"points.theory": {"$lt": theory_points}})
            elif theory_operator == "=":
                query_builder.update({"points.theory": theory_points})

    virtual = request.form['virtual']
    if virtual != "":
        virtual_points = int(request.form['virtual'])
        if virtual_points != "":
            virtual_operator = request.form['virtual-operator']
            if virtual_operator == ">":
                query_builder.update({"points.virtual": {"$gt": virtual_points}})
            elif virtual_operator == "<":
                query_builder.update({"points.virtual": {"$lt": virtual_points}})
            elif virtual_operator == "=":
                query_builder.update({"points.virtual": virtual_points})

    users = User.get_by_filtering(query_builder)
    users_csv = User.export_to_csv(users)
    return Response(users_csv, headers={"Content-Disposition": "attachment; filename=userlist.csv"},
                    content_type="text/csv")
開發者ID:jslvtr,項目名稱:AC41004-Team-2,代碼行數:99,代碼來源:app.py


注:本文中的src.models.user.User.get_by_filtering方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。