本文整理汇总了Python中models.Project.query方法的典型用法代码示例。如果您正苦于以下问题:Python Project.query方法的具体用法?Python Project.query怎么用?Python Project.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get_project(self, project_key):
try:
project_key = ndb.Key(urlsafe=project_key)
except Exception as e:
logging.warn(e)
self.response.set_status(404)
self.render_template("errors/404.html")
return
project = Project.query(ancestor=self.user.key).filter(Project.key == project_key).get()
events = Event.query(ancestor=project.key).fetch()
total_mins = 0
billed_mins = 0
for ev in events:
total_mins = total_mins + ev.elapsed_time
if ev.billed:
billed_mins = billed_mins + ev.elapsed_time
params = {
'project': project,
'events': events,
'total_mins': total_mins,
'billed_mins': billed_mins,
'google_login': True if self.user.google_credentials else False
}
self.render_template('project-details.html', params)
示例2: get_project_list
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get_project_list(self):
result = []
projects = Project.query(ancestor=self.user.key).order(Project.name).fetch()
for proj in projects:
result.append({'key': proj.key.urlsafe(), 'name': proj.name.capitalize()})
self.response.content_type = 'application/json'
self.response.write(json.dumps(result))
示例3: get_project_list
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get_project_list(user_key):
projects = Project.query(ancestor=user_key).order(Project.name).fetch()
proj_array = []
for proj in projects:
p = {}
p['id'] = proj.key.urlsafe()
p['name'] = proj.name
p['hourly_cost'] = proj.hourly_cost
proj_array.append(p)
return proj_array
示例4: get_info
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get_info(self, module_id):
module_id = int(module_id)
module = Module.get_by_id(module_id)
votedCourses = {}
account = get_account()
if account:
votedCourses = account.courses_voted
votedCourses = dict(votedCourses)
newJobsJSON = []
jobs = Project.query(Project.job_type == module.name).fetch()
for job in jobs:
newProject = self.convert_to_project_JSON(job)
newJobsJSON.append(newProject)
info = {
'name': module.name,
'youtube': module.youtube,
'yt_type': module.yt_type,
'courses': module.courses,
'category': module.category,
'jobs': newJobsJSON,
'votedCourses': votedCourses
}
return info
示例5: get_project_list
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get_project_list(self):
projects = Project.query(ancestor=self.user.key).order(Project.name).fetch()
return projects
示例6: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import query [as 别名]
def get(self):
# Render three projects for front page.
projects = Project.query().order(-Project.modified).fetch(limit = 4)
self.templateVars['projects'] = projects
return self.render("index.html")