本文整理汇总了Python中model.Task.select方法的典型用法代码示例。如果您正苦于以下问题:Python Task.select方法的具体用法?Python Task.select怎么用?Python Task.select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Task
的用法示例。
在下文中一共展示了Task.select方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_tasks
# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import select [as 别名]
def read_tasks(user):
try:
week = int(request.query.get("w", 0))
except:
week = 0
current = datetime.now().replace(**ROUND_HOUR) - timedelta(week * ONE_WEEK)
start = current - timedelta(current.weekday())
end = start + timedelta(ONE_WEEK)
tasks = Task.select().where(Task.date > start, Task.date <= end)
return template.render("read_tasks.tpl", tasks=tasks, start=start, week=week, user=user, link="/admin/tasks")
示例2: create_digest
# 需要导入模块: from model import Task [as 别名]
# 或者: from model.Task import select [as 别名]
def create_digest(self, user):
last_sent = user.last_sent or user.created
tasks = Task.select()\
.where((Task.created > last_sent))\
.order_by(Task.user.name, Task.date)
email_params = {
'user': user,
'start': last_sent,
'end': self.now,
'tasks': self.format_tasks(tasks, user),
'sender': settings.SENDER,
'timezone_correct': timedelta(hours=user.timezone)
}
return self.template.render('email_digest.tpl', **email_params)