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