Exemplo n.º 1
0
def _try_to_close_or_open_milestone_when_create_or_edit_task(instance):
    from taiga.projects.milestones import services as milestone_service

    if instance.milestone_id:
        if milestone_service.calculate_milestone_is_closed(instance.milestone):
            milestone_service.close_milestone(instance.milestone)
        else:
            milestone_service.open_milestone(instance.milestone)

    if instance.prev and instance.prev.milestone_id and instance.prev.milestone_id != instance.milestone_id:
        if milestone_service.calculate_milestone_is_closed(instance.prev.milestone):
            milestone_service.close_milestone(instance.prev.milestone)
        else:
            milestone_service.open_milestone(instance.prev.milestone)
Exemplo n.º 2
0
def _try_to_close_or_open_milestone_when_create_or_edit_task(instance):
    from taiga.projects.milestones import services as milestone_service

    if instance.milestone_id:
        if milestone_service.calculate_milestone_is_closed(instance.milestone):
            milestone_service.close_milestone(instance.milestone)
        else:
            milestone_service.open_milestone(instance.milestone)

    if instance.prev and instance.prev.milestone_id and instance.prev.milestone_id != instance.milestone_id:
        if milestone_service.calculate_milestone_is_closed(instance.prev.milestone):
            milestone_service.close_milestone(instance.prev.milestone)
        else:
            milestone_service.open_milestone(instance.prev.milestone)
def _try_to_close_milestone_when_delete_task(instance):
    from taiga.projects.milestones import services

    with suppress(ObjectDoesNotExist):
        if instance.milestone_id and services.calculate_milestone_is_closed(
                instance.milestone):
            services.close_milestone(instance.milestone)
Exemplo n.º 4
0
def _try_to_close_milestone_when_delete_us(instance):
    if instance._importing:
        return

    from taiga.projects.milestones import services as milestone_service

    with suppress(ObjectDoesNotExist):
        if instance.milestone_id and milestone_service.calculate_milestone_is_closed(instance.milestone):
                milestone_service.close_milestone(instance.milestone)
Exemplo n.º 5
0
def test_tasks_closed():
    project = f.ProjectFactory()
    f.MembershipFactory.create(project=project,
                               user=project.owner,
                               is_admin=True)
    milestone1 = f.MilestoneFactory.create(project=project)

    closed_status = f.TaskStatusFactory.create(project=project, is_closed=True)
    f.create_task(project=project, milestone=milestone1, status=closed_status)

    assert services.calculate_milestone_is_closed(milestone1)
Exemplo n.º 6
0
def test_stay_open_with_uss_but_closed_issues():
    project = f.ProjectFactory()
    f.MembershipFactory.create(project=project,
                               user=project.owner,
                               is_admin=True)
    milestone1 = f.MilestoneFactory.create(project=project)

    closed_status = f.IssueStatusFactory.create(project=project,
                                                is_closed=True)
    f.create_issue(project=project, milestone=milestone1, status=closed_status)
    f.create_userstory(project=project, milestone=milestone1)

    assert not services.calculate_milestone_is_closed(milestone1)
Exemplo n.º 7
0
def test_stay_open_with_issues_but_closed_tasks():
    project = f.ProjectFactory()
    f.MembershipFactory.create(project=project, user=project.owner,
                               is_admin=True)
    milestone1 = f.MilestoneFactory.create(project=project)

    tasks_closed_status = f.TaskStatusFactory.create(project=project,
                                                     is_closed=True)
    f.create_task(project=project, milestone=milestone1,
                  taskboard_order=1, status=tasks_closed_status)
    f.create_issue(project=project, milestone=milestone1)

    assert not services.calculate_milestone_is_closed(milestone1)
Exemplo n.º 8
0
def test_uss_closed():
    project = f.ProjectFactory()
    f.MembershipFactory.create(project=project, user=project.owner,
                               is_admin=True)
    milestone1 = f.MilestoneFactory.create(project=project)

    closed_status = f.UserStoryStatusFactory.create(project=project,
                                                    is_closed=True)
    f.create_userstory(project=project, milestone=milestone1,
                       sprint_order=1, status=closed_status,
                       is_closed=True)

    assert services.calculate_milestone_is_closed(milestone1)
Exemplo n.º 9
0
def test_stay_open_with_tasks_but_closed_uss():
    project = f.ProjectFactory()
    f.MembershipFactory.create(project=project, user=project.owner,
                               is_admin=True)
    milestone1 = f.MilestoneFactory.create(project=project)
    us_closed_status = f.UserStoryStatusFactory.create(project=project,
                                                       is_closed=True)
    f.create_userstory(project=project, milestone=milestone1,
                       status=us_closed_status, is_closed=True)

    f.create_task(project=project, milestone=milestone1, user_story=None)

    assert not services.calculate_milestone_is_closed(milestone1)
Exemplo n.º 10
0
def _recalculate_is_closed_for_milestone(milestone):
    """
    Check and update the open or closed condition for the milestone.

    NOTE: [1] This method is useful if the userstory update operation has been done without
              using the ORM (pre_save/post_save model signals).
    """
    from taiga.projects.milestones import services as milestone_service

    # Update is_close attr for the milestone
    if milestone_service.calculate_milestone_is_closed(milestone):
        milestone_service.close_milestone(milestone)
    else:
        milestone_service.open_milestone(milestone)
Exemplo n.º 11
0
def _update_open_or_close_conditions_if_status_has_been_changed(userstory):
    """
    Check and update the open or closed condition for the userstory and its milestone.

    NOTE: [1] This method is useful if the userstory update operation has been done without
              using the ORM (pre_save/post_save model signals).
          [2] Do not use it if the milestone has been previously updated.
    """
    has_changed = False
    if calculate_userstory_is_closed(userstory):
        has_changed = close_userstory(userstory)
    else:
        has_changed = open_userstory(userstory)

    if has_changed and userstory.milestone_id:
        from taiga.projects.milestones import services as milestone_service

        if milestone_service.calculate_milestone_is_closed(
                userstory.milestone):
            milestone_service.close_milestone(userstory.milestone)
        else:
            milestone_service.open_milestone(userstory.milestone)
Exemplo n.º 12
0
def _try_to_close_milestone_when_delete_task(instance):
    from taiga.projects.milestones import services

    with suppress(ObjectDoesNotExist):
        if instance.milestone_id and services.calculate_milestone_is_closed(instance.milestone):
            services.close_milestone(instance.milestone)
Exemplo n.º 13
0
def _try_to_close_milestone_when_delete_us(instance):
    from taiga.projects.milestones import services as milestone_service

    if instance.milestone_id and milestone_service.calculate_milestone_is_closed(instance.milestone):
            milestone_service.close_milestone(instance.milestone)