本文整理汇总了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")