Beispiel #1
0
def test_update_in_bulk_with_ids():
    ids = [1, 2]
    new_values = [{"field1": 1}, {"field2": 2}]
    model = mock.Mock()

    update_in_bulk_with_ids(ids, new_values, model)

    expected_calls = [
        mock.call(id=1), mock.call().update(field1=1),
        mock.call(id=2), mock.call().update(field2=2)
    ]

    model.objects.filter.assert_has_calls(expected_calls)
Beispiel #2
0
def update_userstories_milestone_in_bulk(bulk_data: list, milestone: object):
    """
    Update the milestone of some user stories.
    `bulk_data` should be a list of user story ids:
    """
    user_story_ids = [us_data["us_id"] for us_data in bulk_data]
    new_milestone_values = [{"milestone": milestone.id}] * len(user_story_ids)

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

    db.update_in_bulk_with_ids(user_story_ids, new_milestone_values, model=models.UserStory)
Beispiel #3
0
def update_issues_order_in_bulk(bulk_data):
    """Update the order of some issues.

    `bulk_data` should be a list of tuples with the following format:

    [(<issue id>, <new issue order value>), ...]
    """
    issue_ids = []
    new_order_values = []
    for issue_id, new_order_value in bulk_data:
        issue_ids.append(issue_id)
        new_order_values.append({"order": new_order_value})
    db.update_in_bulk_with_ids(issue_ids, new_order_values, model=models.Issue)
Beispiel #4
0
def update_issues_order_in_bulk(bulk_data):
    """Update the order of some issues.

    `bulk_data` should be a list of tuples with the following format:

    [(<issue id>, <new issue order value>), ...]
    """
    issue_ids = []
    new_order_values = []
    for issue_id, new_order_value in bulk_data:
        issue_ids.append(issue_id)
        new_order_values.append({"order": new_order_value})
    db.update_in_bulk_with_ids(issue_ids, new_order_values, model=models.Issue)
Beispiel #5
0
def update_userstories_milestone_in_bulk(bulk_data:list, milestone:object):
    """
    Update the milestone of some user stories.
    `bulk_data` should be a list of user story ids:
    """
    user_story_ids = [us_data["us_id"] for us_data in bulk_data]
    new_milestone_values = [{"milestone": milestone.id}] * len(user_story_ids)

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

    db.update_in_bulk_with_ids(user_story_ids, new_milestone_values, model=models.UserStory)
Beispiel #6
0
def update_tasks_order_in_bulk(bulk_data: list, field: str, project: object):
    """
    Update the order of some tasks.
    `bulk_data` should be a list of tuples with the following format:

    [(<task id>, {<field>: <value>, ...}), ...]
    """
    task_ids = []
    new_order_values = []
    for task_data in bulk_data:
        task_ids.append(task_data["task_id"])
        new_order_values.append({field: task_data["order"]})

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

    db.update_in_bulk_with_ids(task_ids, new_order_values, model=models.Task)
Beispiel #7
0
def update_userstories_order_in_bulk(bulk_data: list, field: str, project: object):
    """
    Update the order of some user stories.
    `bulk_data` should be a list of tuples with the following format:

    [(<user story id>, {<field>: <value>, ...}), ...]
    """
    user_story_ids = []
    new_order_values = []
    for us_data in bulk_data:
        user_story_ids.append(us_data["us_id"])
        new_order_values.append({field: us_data["order"]})

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

    db.update_in_bulk_with_ids(user_story_ids, new_order_values, model=models.UserStory)
Beispiel #8
0
def update_tasks_order_in_bulk(bulk_data: list, field: str, project: object):
    """
    Update the order of some tasks.
    `bulk_data` should be a list of tuples with the following format:

    [(<task id>, {<field>: <value>, ...}), ...]
    """
    task_ids = []
    new_order_values = []
    for task_data in bulk_data:
        task_ids.append(task_data["task_id"])
        new_order_values.append({field: task_data["order"]})

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

    db.update_in_bulk_with_ids(task_ids, new_order_values, model=models.Task)
def update_projects_order_in_bulk(bulk_data:list, field:str, user):
    """
    Update the order of user projects in the user membership.
    `bulk_data` should be a list of tuples with the following format:

    [(<project id>, {<field>: <value>, ...}), ...]
    """
    membership_ids = []
    new_order_values = []
    for membership_data in bulk_data:
        project_id = membership_data["project_id"]
        membership = user.memberships.get(project_id=project_id)
        membership_ids.append(membership.id)
        new_order_values.append({field: membership_data["order"]})

    from taiga.base.utils import db

    db.update_in_bulk_with_ids(membership_ids, new_order_values, model=models.Membership)
def update_projects_order_in_bulk(bulk_data:list, field:str, user):
    """
    Update the order of user projects in the user membership.
    `bulk_data` should be a list of tuples with the following format:

    [(<project id>, {<field>: <value>, ...}), ...]
    """
    membership_ids = []
    new_order_values = []
    for membership_data in bulk_data:
        project_id = membership_data["project_id"]
        membership = user.memberships.get(project_id=project_id)
        membership_ids.append(membership.id)
        new_order_values.append({field: membership_data["order"]})

    from taiga.base.utils import db

    db.update_in_bulk_with_ids(membership_ids, new_order_values, model=models.Membership)
Beispiel #11
0
def update_userstories_order_in_bulk(bulk_data:list, field:str, project:object):
    """
    Update the order of some user stories.
    `bulk_data` should be a list of tuples with the following format:

    [(<user story id>, {<field>: <value>, ...}), ...]
    """
    user_story_ids = []
    new_order_values = []
    for us_data in bulk_data:
        user_story_ids.append(us_data["us_id"])
        new_order_values.append({field: us_data["order"]})

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

    db.update_in_bulk_with_ids(user_story_ids, new_order_values, model=models.UserStory)