当前位置: 首页>>代码示例>>Python>>正文


Python sequences.create函数代码示例

本文整理汇总了Python中taiga.projects.references.sequences.create函数的典型用法代码示例。如果您正苦于以下问题:Python create函数的具体用法?Python create怎么用?Python create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: store_task

def store_task(project, task):
    if 'status' not in task and project.default_task_status:
        task['status'] = project.default_task_status.name

    serialized = serializers.TaskExportSerializer(data=task, context={"project": project})
    if serialized.is_valid():
        serialized.object.project = project
        if serialized.object.owner is None:
            serialized.object.owner = serialized.object.project.owner
        serialized.object._importing = True
        serialized.object._not_notify = True

        serialized.save()

        if serialized.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized.object.ref)
        else:
            serialized.object.ref, _ = refs.make_reference(serialized.object, project)
            serialized.object.save()

        for task_attachment in task.get('attachments', []):
            store_attachment(project, serialized.object, task_attachment)

        for history in task.get('history', []):
            store_history(project, serialized.object, history)

        return serialized

    add_errors("tasks", serialized.errors)
    return None
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:33,代码来源:service.py

示例2: test_sequences

def test_sequences(seq):
    seqname = "foo"
    assert not seq.exists(seqname)

    # Create and check values
    seq.create(seqname)
    assert seq.exists(seqname)
    assert seq.next_value(seqname) == 1
    assert seq.next_value(seqname) == 2

    # Delete sequence
    seq.delete(seqname)
    assert not seq.exists(seqname)

    # Create new seq with same name
    # after previously deleted it
    seq.create(seqname)
    assert seq.next_value(seqname) == 1

    # Alter sequence
    seq.alter(seqname, 4)
    assert seq.next_value(seqname) == 5

    # Delete after alter
    seq.delete(seqname)
    assert not seq.exists(seqname)
开发者ID:6ft,项目名称:taiga-back,代码行数:26,代码来源:test_project_references_sequences.py

示例3: store_issue

def store_issue(project, data):
    validator = validators.IssueExportValidator(data=data, context={"project": project})

    if "type" not in data and project.default_issue_type:
        data["type"] = project.default_issue_type.name

    if "status" not in data and project.default_issue_status:
        data["status"] = project.default_issue_status.name

    if "priority" not in data and project.default_priority:
        data["priority"] = project.default_priority.name

    if "severity" not in data and project.default_severity:
        data["severity"] = project.default_severity.name

    if validator.is_valid():
        validator.object.project = project
        if validator.object.owner is None:
            validator.object.owner = validator.object.project.owner
        validator.object._importing = True
        validator.object._not_notify = True

        validator.save()
        validator.save_watchers()

        if validator.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, validator.object.ref)
        else:
            validator.object.ref, _ = refs.make_reference(validator.object, project)
            validator.object.save()

        for attachment in data.get("attachments", []):
            _store_attachment(project, validator.object, attachment)

        history_entries = data.get("history", [])
        statuses = {s.name: s.id for s in project.issue_statuses.all()}
        for history in history_entries:
            _store_history(project, validator.object, history, statuses)

        if not history_entries:
            take_snapshot(validator.object, user=validator.object.owner)

        custom_attributes_values = data.get("custom_attributes_values", None)
        if custom_attributes_values:
            custom_attributes = validator.object.project.issuecustomattributes.all().values('id', 'name')
            custom_attributes_values = \
                _use_id_instead_name_as_key_in_custom_attributes_values(custom_attributes,
                                                                        custom_attributes_values)
            _store_custom_attributes_values(validator.object, custom_attributes_values,
                                            "issue",
                                            validators.IssueCustomAttributesValuesExportValidator)

        return validator

    add_errors("issues", validator.errors)
    return None
开发者ID:taigaio,项目名称:taiga-back,代码行数:59,代码来源:store.py

示例4: store_user_story

def store_user_story(project, data):
    if "status" not in data and project.default_us_status:
        data["status"] = project.default_us_status.name

    us_data = {key: value for key, value in data.items() if key not in
               ["role_points", "custom_attributes_values", 'generated_from_task', 'generated_from_issue']}

    validator = validators.UserStoryExportValidator(data=us_data, context={"project": project})

    if validator.is_valid():
        validator.object.project = project
        if validator.object.owner is None:
            validator.object.owner = validator.object.project.owner
        validator.object._importing = True
        validator.object._not_notify = True

        validator.save()
        validator.save_watchers()

        if validator.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, validator.object.ref)
        else:
            validator.object.ref, _ = refs.make_reference(validator.object, project)
            validator.object.save()

        for us_attachment in data.get("attachments", []):
            _store_attachment(project, validator.object, us_attachment)

        for role_point in data.get("role_points", []):
            _store_role_point(project, validator.object, role_point)

        history_entries = data.get("history", [])
        statuses = {s.name: s.id for s in project.us_statuses.all()}
        for history in history_entries:
            _store_history(project, validator.object, history, statuses)

        if not history_entries:
            take_snapshot(validator.object, user=validator.object.owner)

        custom_attributes_values = data.get("custom_attributes_values", None)
        if custom_attributes_values:
            custom_attributes = validator.object.project.userstorycustomattributes.all().values('id', 'name')
            custom_attributes_values = \
                _use_id_instead_name_as_key_in_custom_attributes_values(custom_attributes,
                                                                        custom_attributes_values)

            _store_custom_attributes_values(validator.object, custom_attributes_values,
                                            "user_story",
                                            validators.UserStoryCustomAttributesValuesExportValidator)

        return validator

    add_errors("user_stories", validator.errors)
    return None
开发者ID:taigaio,项目名称:taiga-back,代码行数:57,代码来源:store.py

示例5: store_user_story

def store_user_story(project, data):
    if "status" not in data and project.default_us_status:
        data["status"] = project.default_us_status.name

    us_data = {key: value for key, value in data.items() if key not in ["role_points", "custom_attributes_values"]}
    serialized = serializers.UserStoryExportSerializer(data=us_data, context={"project": project})

    if serialized.is_valid():
        serialized.object.project = project
        if serialized.object.owner is None:
            serialized.object.owner = serialized.object.project.owner
        serialized.object._importing = True
        serialized.object._not_notify = True

        serialized.save()
        serialized.save_watchers()

        if serialized.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized.object.ref)
        else:
            serialized.object.ref, _ = refs.make_reference(serialized.object, project)
            serialized.object.save()

        for us_attachment in data.get("attachments", []):
            store_attachment(project, serialized.object, us_attachment)

        for role_point in data.get("role_points", []):
            store_role_point(project, serialized.object, role_point)

        history_entries = data.get("history", [])
        for history in history_entries:
            store_history(project, serialized.object, history)

        if not history_entries:
            take_snapshot(serialized.object, user=serialized.object.owner)

        custom_attributes_values = data.get("custom_attributes_values", None)
        if custom_attributes_values:
            custom_attributes = serialized.object.project.userstorycustomattributes.all().values("id", "name")
            custom_attributes_values = _use_id_instead_name_as_key_in_custom_attributes_values(
                custom_attributes, custom_attributes_values
            )
            store_custom_attributes_values(
                serialized.object,
                custom_attributes_values,
                "user_story",
                serializers.UserStoryCustomAttributesValuesExportSerializer,
            )

        return serialized

    add_errors("user_stories", serialized.errors)
    return None
开发者ID:adebayo-dealdey,项目名称:taiga-back,代码行数:56,代码来源:service.py

示例6: store_issue

def store_issue(project, data):
    serialized = serializers.IssueExportSerializer(data=data, context={"project": project})

    if "type" not in data and project.default_issue_type:
        data["type"] = project.default_issue_type.name

    if "status" not in data and project.default_issue_status:
        data["status"] = project.default_issue_status.name

    if "priority" not in data and project.default_priority:
        data["priority"] = project.default_priority.name

    if "severity" not in data and project.default_severity:
        data["severity"] = project.default_severity.name

    if serialized.is_valid():
        serialized.object.project = project
        if serialized.object.owner is None:
            serialized.object.owner = serialized.object.project.owner
        serialized.object._importing = True
        serialized.object._not_notify = True

        serialized.save()

        if serialized.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized.object.ref)
        else:
            serialized.object.ref, _ = refs.make_reference(serialized.object, project)
            serialized.object.save()

        for attachment in data.get("attachments", []):
            store_attachment(project, serialized.object, attachment)

        for history in data.get("history", []):
            store_history(project, serialized.object, history)

        custom_attributes_values = data.get("custom_attributes_values", None)
        if custom_attributes_values:
            custom_attributes = serialized.object.project.issuecustomattributes.all().values('id', 'name')
            custom_attributes_values = _use_id_instead_name_as_key_in_custom_attributes_values(custom_attributes,
                                                                                               custom_attributes_values)
            store_custom_attributes_values(serialized.object, custom_attributes_values,
                                           "issue", serializers.IssueCustomAttributesValuesExportSerializer)

        return serialized

    add_errors("issues", serialized.errors)
    return None
开发者ID:SashaBorandi,项目名称:taiga-back,代码行数:51,代码来源:service.py

示例7: store_task

def store_task(project, data):
    if "status" not in data and project.default_task_status:
        data["status"] = project.default_task_status.name

    serialized = serializers.TaskExportSerializer(data=data, context={"project": project})
    if serialized.is_valid():
        serialized.object.project = project
        if serialized.object.owner is None:
            serialized.object.owner = serialized.object.project.owner
        serialized.object._importing = True
        serialized.object._not_notify = True

        serialized.save()
        serialized.save_watchers()

        if serialized.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized.object.ref)
        else:
            serialized.object.ref, _ = refs.make_reference(serialized.object, project)
            serialized.object.save()

        for task_attachment in data.get("attachments", []):
            store_attachment(project, serialized.object, task_attachment)

        history_entries = data.get("history", [])
        for history in history_entries:
            store_history(project, serialized.object, history)

        if not history_entries:
            take_snapshot(serialized.object, user=serialized.object.owner)

        custom_attributes_values = data.get("custom_attributes_values", None)
        if custom_attributes_values:
            custom_attributes = serialized.object.project.taskcustomattributes.all().values('id', 'name')
            custom_attributes_values = _use_id_instead_name_as_key_in_custom_attributes_values(
                                                    custom_attributes, custom_attributes_values)
            store_custom_attributes_values(serialized.object, custom_attributes_values,
                                           "task", serializers.TaskCustomAttributesValuesExportSerializer)

        return serialized

    add_errors("tasks", serialized.errors)
    return None
开发者ID:Rademade,项目名称:taiga-back,代码行数:46,代码来源:service.py

示例8: store_issue

def store_issue(project, data):
    serialized = serializers.IssueExportSerializer(data=data, context={"project": project})

    if 'type' not in data and project.default_issue_type:
        data['type'] = project.default_issue_type.name

    if 'status' not in data and project.default_issue_status:
        data['status'] = project.default_issue_status.name

    if 'priority' not in data and project.default_priority:
        data['priority'] = project.default_priority.name

    if 'severity' not in data and project.default_severity:
        data['severity'] = project.default_severity.name

    if serialized.is_valid():
        serialized.object.project = project
        if serialized.object.owner is None:
            serialized.object.owner = serialized.object.project.owner
        serialized.object._importing = True
        serialized.object._not_notify = True

        serialized.save()

        if serialized.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized.object.ref)
        else:
            serialized.object.ref, _ = refs.make_reference(serialized.object, project)
            serialized.object.save()

        for attachment in data.get('attachments', []):
            store_attachment(project, serialized.object, attachment)
        for history in data.get('history', []):
            store_history(project, serialized.object, history)
        return serialized
    add_errors("issues", serialized.errors)
    return None
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:40,代码来源:service.py

示例9: store_user_story

def store_user_story(project, userstory):
    if 'status' not in userstory and project.default_us_status:
        userstory['status'] = project.default_us_status.name

    userstory_data = {}
    for key, value in userstory.items():
        if key != 'role_points':
            userstory_data[key] = value
    serialized_us = serializers.UserStoryExportSerializer(data=userstory_data, context={"project": project})
    if serialized_us.is_valid():
        serialized_us.object.project = project
        if serialized_us.object.owner is None:
            serialized_us.object.owner = serialized_us.object.project.owner
        serialized_us.object._importing = True
        serialized_us.object._not_notify = True

        serialized_us.save()

        if serialized_us.object.ref:
            sequence_name = refs.make_sequence_name(project)
            if not seq.exists(sequence_name):
                seq.create(sequence_name)
            seq.set_max(sequence_name, serialized_us.object.ref)
        else:
            serialized_us.object.ref, _ = refs.make_reference(serialized_us.object, project)
            serialized_us.object.save()

        for us_attachment in userstory.get('attachments', []):
            store_attachment(project, serialized_us.object, us_attachment)

        for role_point in userstory.get('role_points', []):
            store_role_point(project, serialized_us.object, role_point)

        for history in userstory.get('history', []):
            store_history(project, serialized_us.object, history)

        return serialized_us
    add_errors("user_stories", serialized_us.errors)
    return None
开发者ID:FlorianBezagu,项目名称:taiga-back,代码行数:39,代码来源:service.py


注:本文中的taiga.projects.references.sequences.create函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。