• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python services.apply_order_updates函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: update_tasks_order_in_bulk

def update_tasks_order_in_bulk(bulk_data: list, field: str, project: object,
                               user_story: object=None, status: object=None, milestone: object=None):
    """
    Updates the order of the tasks specified adding the extra updates needed
    to keep consistency.

    [{'task_id': <value>, 'order': <value>}, ...]
    """
    tasks = project.tasks.all()
    if user_story is not None:
        tasks = tasks.filter(user_story=user_story)
    if status is not None:
        tasks = tasks.filter(status=status)
    if milestone is not None:
        tasks = tasks.filter(milestone=milestone)

    task_orders = {task.id: getattr(task, field) for task in tasks}
    new_task_orders = {e["task_id"]: e["order"] for e in bulk_data}
    apply_order_updates(task_orders, new_task_orders)

    task_ids = task_orders.keys()
    events.emit_event_for_ids(ids=task_ids,
                              content_type="tasks.task",
                              projectid=project.pk)

    db.update_attr_in_bulk_for_ids(task_orders, field, models.Task)
    return task_orders
开发者ID:aminadha,项目名称:taiga-back,代码行数:27,代码来源:services.py


示例2: update_userstories_milestone_in_bulk

def update_userstories_milestone_in_bulk(bulk_data: list, milestone: object):
    """
    Update the milestone and the milestone order of some user stories adding
    the extra orders needed to keep consistency.
    `bulk_data` should be a list of dicts with the following format:
    [{'us_id': <value>, 'order': <value>}, ...]
    """
    user_stories = milestone.user_stories.all()
    us_orders = {us.id: getattr(us, "sprint_order") for us in user_stories}
    new_us_orders = {}
    for e in bulk_data:
        new_us_orders[e["us_id"]] = e["order"]
        # The base orders where we apply the new orders must containg all
        # the values
        us_orders[e["us_id"]] = e["order"]

    apply_order_updates(us_orders, new_us_orders)

    us_milestones = {e["us_id"]: milestone.id for e in bulk_data}
    user_story_ids = us_milestones.keys()

    events.emit_event_for_ids(ids=user_story_ids,
                              content_type="userstories.userstory",
                              projectid=milestone.project.pk)

    db.update_attr_in_bulk_for_ids(us_milestones, "milestone_id",
                                   model=models.UserStory)
    db.update_attr_in_bulk_for_ids(us_orders, "sprint_order", models.UserStory)

    # Updating the milestone for the tasks
    Task.objects.filter(
        user_story_id__in=[e["us_id"] for e in bulk_data]).update(
        milestone=milestone)

    return us_orders
开发者ID:taigaio,项目名称:taiga-back,代码行数:35,代码来源:services.py


示例3: update_userstories_order_in_bulk

def update_userstories_order_in_bulk(bulk_data: list, field: str,
                                     project: object,
                                     status: object = None,
                                     milestone: object = None):
    """
    Updates the order of the userstories specified adding the extra updates
    needed to keep consistency.
    `bulk_data` should be a list of dicts with the following format:
    `field` is the order field used

    [{'us_id': <value>, 'order': <value>}, ...]
    """
    user_stories = project.user_stories.all()
    if status is not None:
        user_stories = user_stories.filter(status=status)
    if milestone is not None:
        user_stories = user_stories.filter(milestone=milestone)

    us_orders = {us.id: getattr(us, field) for us in user_stories}
    new_us_orders = {e["us_id"]: e["order"] for e in bulk_data}
    apply_order_updates(us_orders, new_us_orders, remove_equal_original=True)

    user_story_ids = us_orders.keys()
    events.emit_event_for_ids(ids=user_story_ids,
                              content_type="userstories.userstory",
                              projectid=project.pk)
    db.update_attr_in_bulk_for_ids(us_orders, field, models.UserStory)
    return us_orders
开发者ID:taigaio,项目名称:taiga-back,代码行数:28,代码来源:services.py


示例4: update_epic_related_userstories_order_in_bulk

def update_epic_related_userstories_order_in_bulk(bulk_data: list, epic: object):
    """
    Updates the order of the related userstories of an specific epic.
    `bulk_data` should be a list of dicts with the following format:
    `epic` is the epic with related stories.

    [{'us_id': <value>, 'order': <value>}, ...]
    """
    related_user_stories = epic.relateduserstory_set.all()
    # select_related
    rus_orders = {rus.id: rus.order for rus in related_user_stories}

    rus_conversion = {rus.user_story_id: rus.id for rus in related_user_stories}
    new_rus_orders = {rus_conversion[e["us_id"]]: e["order"] for e in bulk_data
                      if e["us_id"] in rus_conversion}

    apply_order_updates(rus_orders, new_rus_orders)

    if rus_orders:
        related_user_story_ids = rus_orders.keys()
        events.emit_event_for_ids(ids=related_user_story_ids,
                                  content_type="epics.relateduserstory",
                                  projectid=epic.project_id)

        db.update_attr_in_bulk_for_ids(rus_orders, "order", models.RelatedUserStory)

    return rus_orders
开发者ID:maniacs-satm,项目名称:taiga-back,代码行数:27,代码来源:services.py


示例5: update_tasks_milestone_in_bulk

def update_tasks_milestone_in_bulk(bulk_data: list, milestone: object):
    """
    Update the milestone and the milestone order of some tasks adding
    the extra orders needed to keep consistency.
    `bulk_data` should be a list of dicts with the following format:
    [{'task_id': <value>, 'order': <value>}, ...]
    """
    tasks = milestone.tasks.all()
    task_orders = {task.id: getattr(task, "taskboard_order") for task in tasks}
    new_task_orders = {}
    for e in bulk_data:
        new_task_orders[e["task_id"]] = e["order"]
        # The base orders where we apply the new orders must containg all
        # the values
        task_orders[e["task_id"]] = e["order"]

    apply_order_updates(task_orders, new_task_orders)

    task_milestones = {e["task_id"]: milestone.id for e in bulk_data}
    task_ids = task_milestones.keys()

    events.emit_event_for_ids(ids=task_ids,
                              content_type="tasks.task",
                              projectid=milestone.project.pk)

    db.update_attr_in_bulk_for_ids(task_milestones, "milestone_id",
                                   model=models.Task)

    db.update_attr_in_bulk_for_ids(task_orders, "taskboard_order", models.Task)

    return task_milestones
开发者ID:taigaio,项目名称:taiga-back,代码行数:31,代码来源:services.py


示例6: test_apply_order_not_include_noop

def test_apply_order_not_include_noop():
    orders = {
        "a": 1,
    }
    new_orders = {
        "a": 1,
    }
    apply_order_updates(orders, new_orders, remove_equal_original=True)
    assert orders == {}
开发者ID:taigaio,项目名称:taiga-back,代码行数:9,代码来源:test_order_updates.py


示例7: test_apply_order_updates_two_elements

def test_apply_order_updates_two_elements():
    orders = {
        "a": 0,
        "b": 1,
    }
    new_orders = {
        "b": 0
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "b": 0,
        "a": 1
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:13,代码来源:test_order_updates.py


示例8: test_apply_order_maintain_new_values

def test_apply_order_maintain_new_values():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 4,
        "e": 7,
        "f": 6,
        "g": 7,
    }
    new_orders = {
        "e": 7,
        "g": 8,
    }
    expected = {"g": 8}
    apply_order_updates(orders, new_orders, remove_equal_original=True)
    assert expected == orders
开发者ID:taigaio,项目名称:taiga-back,代码行数:17,代码来源:test_order_updates.py


示例9: test_apply_order_put_it_first

def test_apply_order_put_it_first():
    orders = {
        "a": 0,
        "b": 1,
        "c": 2,
        "z": 99,
    }
    new_orders = {
        "z": 0,
    }
    apply_order_updates(orders, new_orders, remove_equal_original=True)
    assert orders == {
        "z": 0,
        "a": 1,
        "b": 2,
        "c": 3,
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:17,代码来源:test_order_updates.py


示例10: test_apply_order_updates_one_element_backward

def test_apply_order_updates_one_element_backward():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 4,
        "e": 5,
        "f": 6
    }
    new_orders = {
        "d": 2
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "d": 2,
        "b": 3,
        "c": 4
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:18,代码来源:test_order_updates.py


示例11: test_apply_order_refresh

def test_apply_order_refresh():
    orders = {
        "a": 0,
        "b": 0,
        "c": 0,
        "d": 1,
        "w": 99,
        "z": 0,
    }
    new_orders = {
        "z": 0,
    }
    apply_order_updates(orders, new_orders, remove_equal_original=True)
    assert orders == {
        "a": 1,
        "b": 1,
        "c": 1,
        "d": 2,
        "w": 100,
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:20,代码来源:test_order_updates.py


示例12: test_apply_order_updates_duplicated_orders

def test_apply_order_updates_duplicated_orders():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 3,
        "e": 3,
        "f": 4
    }
    new_orders = {
        "a": 3
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "a": 3,
        "c": 4,
        "d": 4,
        "e": 4,
        "f": 5
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:20,代码来源:test_order_updates.py


示例13: update_epics_order_in_bulk

def update_epics_order_in_bulk(bulk_data: list, field: str, project: object):
    """
    Update the order of some epics.
    `bulk_data` should be a list of tuples with the following format:

    [{'epic_id': <value>, 'order': <value>}, ...]
    """
    epics = project.epics.all()

    epic_orders = {e.id: getattr(e, field) for e in epics}
    new_epic_orders = {d["epic_id"]: d["order"] for d in bulk_data}
    apply_order_updates(epic_orders, new_epic_orders)

    epic_ids = epic_orders.keys()
    events.emit_event_for_ids(ids=epic_ids,
                              content_type="epics.epic",
                              projectid=project.pk)

    db.update_attr_in_bulk_for_ids(epic_orders, field, models.Epic)
    return epic_orders
开发者ID:maniacs-satm,项目名称:taiga-back,代码行数:20,代码来源:services.py


示例14: test_apply_order_updates_multiple_elements_forward

def test_apply_order_updates_multiple_elements_forward():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 4,
        "e": 5,
        "f": 6
    }
    new_orders = {
        "a": 4,
        "b": 5
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "a": 4,
        "b": 5,
        "d": 6,
        "e": 7,
        "f": 8
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:21,代码来源:test_order_updates.py


示例15: test_apply_order_updates_multiple_elements_duplicated_orders

def test_apply_order_updates_multiple_elements_duplicated_orders():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 3,
        "e": 3,
        "f": 4
    }
    new_orders = {
        "c": 3,
        "d": 3,
        "a": 4
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "c": 3,
        "d": 3,
        "a": 4,
        "e": 5,
        "f": 6
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:22,代码来源:test_order_updates.py


示例16: test_apply_order_invalid_new_order

def test_apply_order_invalid_new_order():
    orders = {
        "a": 1,
        "b": 2,
        "c": 3,
        "d": 3,
        "e": 3,
        "f": 4
    }
    new_orders = {
        "c": 3,
        "d": 3,
        "x": 3,
        "a": 4
    }
    apply_order_updates(orders, new_orders)
    assert orders == {
        "c": 3,
        "d": 3,
        "a": 4,
        "e": 5,
        "f": 6
    }
开发者ID:taigaio,项目名称:taiga-back,代码行数:23,代码来源:test_order_updates.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python services.add_vote函数代码示例发布时间:2022-05-27
下一篇:
Python sequences.set_max函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap