本文整理匯總了Python中models.Project.find方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.find方法的具體用法?Python Project.find怎麽用?Python Project.find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Project
的用法示例。
在下文中一共展示了Project.find方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: api_save_project
# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import find [as 別名]
def api_save_project(request, *, id, title, summary):
if not title or not title.strip():
raise APIValueError('title', 'title cannot be empty.')
if not summary or not summary.strip():
raise APIValueError('summary', 'summary cannot be empty.')
project = yield from Project.find(id)
project.status = True
project.title = title
project.summary =summary
yield from project.update()
return project
示例2: getAllProject
# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import find [as 別名]
def getAllProject():
projectList = []
for item in Project.find():
project = {
'id' : item['id'],
'name' : item['name'],
'description' : item['description'],
}
projectList.append(project)
return projectList
示例3: api_delete_project
# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import find [as 別名]
def api_delete_project(request, *, id):
check_admin(request)
project = yield from Project.find(id)
yield from project.remove()
return dict(id=id)
示例4: api_get_project
# 需要導入模塊: from models import Project [as 別名]
# 或者: from models.Project import find [as 別名]
def api_get_project(*, id):
project = yield from Project.find(id)
charts = yield from Chart.findAll('project_id=?', [id], orderBy='created_at desc')
for chart in charts:
chart.option = json.loads(chart.option)
return dict(project=project, charts=charts)