本文整理汇总了Python中models.Project.select方法的典型用法代码示例。如果您正苦于以下问题:Python Project.select方法的具体用法?Python Project.select怎么用?Python Project.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Project
的用法示例。
在下文中一共展示了Project.select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_user_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def load_user_project(user_id, project_id):
page = int(request.args.get('page'))
page_size = int(request.args.get('pageSize'))
project = (Project.select()
.join(ProjectUser)
.where(ProjectUser.app_user == user_id,
ProjectUser.project == project_id
).first())
return jsonify({ 'project': project.deep_serialized(page, page_size, user_id) }), 200
示例2: test_create_project
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def test_create_project(self):
"""Make sure it creates a project."""
create_project(project_id='001', project_description='This could be the same.')
p = Project.select().where(Project.project_id == '001')
q = Project.delete().where(Project.project_id == '001')
q.execute()
self.assertEqual(str(p), ("<class 'models.Project'> SELECT `t1`.`id`,"
" `t1`.`project_id`, `t1`.`project_description` "
"FROM `project` AS t1 WHERE (`t1`.`project_id` = %s) "
"['001']"))
示例3: get
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def get(self):
list_projects = Project.select()
iterator = list_projects.iterator()
result_set = []
for data in iterator:
model_info = model_to_dict(data)
model_info['build_amount'] = data.build_amount
model_info['last_status'] = data.last_status
result_set.append(model_info)
return result_set
示例4: projects
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def projects():
req = request.get_json()
message = ""
try:
page = req['page']
page_size = req['pageSize']
except (TypeError, KeyError):
page = 1
page_size = 20
if request.method == 'POST':
try:
request_error = False
title = req['title']
comments = req['comments']
stacks = req['stacks']
probe_type = req['probeType']
except KeyError:
request_error = True
if request_error:
return jsonify({ 'message': 'Insufficient information to create project' }), 400
try:
project = Project.create(title=title, comments=comments, probe_type=probe_type)
if req['markerOptions']:
marker_options = req['markerOptions']
for marker_name in marker_options:
try:
marker_option = MarkerOption.get(MarkerOption.name == marker_name)
ProjectMarkerOption.create(project = project, marker_option = marker_option)
except Exception as ex:
print("line 74")
print ex
if req['users']:
users = req['users']
for user in users:
try:
ProjectUser.create(app_user = user['id'], project = project)
except Exception as ex:
print ex
for stack in stacks:
try:
project_stack = ProjectStack.create(project=project, stack = stack['stackId'])
probe_setting = stack['probeSettings']
probe_position = json.loads(probe_setting['position'])
ProbeSetting.create(x_offset=int(probe_position['xOffset']),
y_offset=int(probe_position['yOffset']),
project_stack=project_stack,
label=probe_position['label']
)
except Exception as ex:
print ex
message = "Project created"
except Exception as ex:
print ex
projects = (Project.select()
.order_by(Project.created_date.desc()))
# .paginate(page, page_size))
return jsonify({
'message': message,
'projects': [project.serialized for project in projects],
'projectCount': SelectQuery(models.Project).count()
}), 201
示例5: get_project_reports_list
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def get_project_reports_list():
all_projects = Project.select()
projects = [proj for proj in all_projects if len([s for s in proj.project_stacks]) > 0]
return jsonify({ 'projects': [project.serialized for project in projects] })
示例6: projects_past
# 需要导入模块: from models import Project [as 别名]
# 或者: from models.Project import select [as 别名]
def projects_past():
projects = Project.select().where(Project.active == False)
return render_template('projects/index.html', projects=projects, num_projects=projects.count())