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


Python DataManager.delete_event方法代码示例

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


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

示例1: empty_trash

# 需要导入模块: from app.helpers.data import DataManager [as 别名]
# 或者: from app.helpers.data.DataManager import delete_event [as 别名]
def empty_trash():
    from app import current_app as app

    with app.app_context():
        events = Event.query.filter(Event.deleted_at.isnot(None)).all()
        users = User.query.filter(User.deleted_at.isnot(None)).all()
        sessions = Session.query.filter(Session.deleted_at.isnot(None)).all()
        pending_orders = Order.query.filter_by(status="pending")

        for event in events:
            if datetime.now() - event.deleted_at >= timedelta(days=30):
                DataManager.delete_event(event.id)

        for user in users:
            if datetime.now() - user.deleted_at >= timedelta(days=30):
                transaction = transaction_class(Event)
                transaction.query.filter_by(user_id=user.id).delete()
                delete_from_db(user, "User deleted permanently")

        for session_ in sessions:
            if datetime.now() - session_.deleted_at >= timedelta(days=30):
                delete_from_db(session_, "Session deleted permanently")

        for pending_order in pending_orders:
            if datetime.now() - pending_order.created_at >= timedelta(days=3):
                pending_order.status = "expired"
                save_to_db(pending_order, "Pending order expired.")
开发者ID:SaptakS,项目名称:open-event-orga-server,代码行数:29,代码来源:scheduled_jobs.py

示例2: empty_trash

# 需要导入模块: from app.helpers.data import DataManager [as 别名]
# 或者: from app.helpers.data.DataManager import delete_event [as 别名]
def empty_trash():
    with app.app_context():
        events = Event.query.filter_by(in_trash=True)
        users = User.query.filter_by(in_trash=True)
        sessions = Session.query.filter_by(in_trash=True)
        for event in events:
            if datetime.now() - event.trash_date >= timedelta(days=30):
                DataManager.delete_event(event.id)

        for user in users:
            if datetime.now() - user.trash_date >= timedelta(days=30):
                transaction = transaction_class(Event)
                transaction.query.filter_by(user_id=user.id).delete()
                delete_from_db(user, "User deleted permanently")

        for session_ in sessions:
            if datetime.now() - session_.trash_date >= timedelta(days=30):
                delete_from_db(session_, "Session deleted permanently")
开发者ID:ashishpahwa7,项目名称:open-event-orga-server,代码行数:20,代码来源:scheduled_jobs.py

示例3: delete_view

# 需要导入模块: from app.helpers.data import DataManager [as 别名]
# 或者: from app.helpers.data.DataManager import delete_event [as 别名]
def delete_view(event_id):
    if request.method == "GET":
        DataManager.delete_event(event_id)
    flash("Your event has been permanently deleted.", "danger")
    return redirect(url_for('sadmin_events.index_view'))
开发者ID:codebhendi,项目名称:open-event-orga-server,代码行数:7,代码来源:events.py


注:本文中的app.helpers.data.DataManager.delete_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。