當前位置: 首頁>>代碼示例>>Python>>正文


Python Project.select方法代碼示例

本文整理匯總了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
開發者ID:BlaiseGratton,項目名稱:DataAnalysisNgin,代碼行數:11,代碼來源:project_routes.py

示例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']"))
開發者ID:dsantosp12,項目名稱:NapAdmin,代碼行數:12,代碼來源:tests.py

示例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
開發者ID:joepreludian,項目名稱:deployer-ci,代碼行數:16,代碼來源:model_api.py

示例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
開發者ID:BlaiseGratton,項目名稱:DataAnalysisNgin,代碼行數:63,代碼來源:project_routes.py

示例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] })
開發者ID:BlaiseGratton,項目名稱:DataAnalysisNgin,代碼行數:6,代碼來源:report_routes.py

示例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())
開發者ID:brendanWeb,項目名稱:old-brendanhenderson.com,代碼行數:5,代碼來源:views.py


注:本文中的models.Project.select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。