当前位置: 首页>>代码示例>>Python>>正文


Python User.export_to_csv方法代码示例

本文整理汇总了Python中src.models.user.User.export_to_csv方法的典型用法代码示例。如果您正苦于以下问题:Python User.export_to_csv方法的具体用法?Python User.export_to_csv怎么用?Python User.export_to_csv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.models.user.User的用法示例。


在下文中一共展示了User.export_to_csv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: export_users

# 需要导入模块: from src.models.user import User [as 别名]
# 或者: from src.models.user.User import export_to_csv [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.export_to_csv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。