def check_sprint_finishing_before_deadline(project_id, sprint_id,
                                           sprint_finish_date):
    current_sprint = Milestone.objects.filter(project=project_id,
                                              id=sprint_id).first()
    # TODO: Remove not
    if not current_sprint.closed:  # check closed sprint on a deadline
        current_date = time.strptime(datetime.today().strftime('%Y-%m-%d'),
                                     '%Y-%m-%d')
        # calculate how much time until finish
        days_until_finish = settings_for_push.get_delta_dates(
            current_date, sprint_finish_date).days
        #  TODO: remove +55
        if days_until_finish + 55 > 0:
            settings_for_push.push_message_to_manager(
                project_id, "Sprint " + current_sprint.name + " has no tasks, "
                "but has already finished. You can add some new there.",
                settings_for_push.NotificationType.
                SPRINT_FINISHED_BEFORE_DEADLINE)
            # possible case that checking was disabled before deadline
            enable_blocked_tasks_notifications(project_id)
            Timer(settings_for_push.SEC_PER_DAY,
                  check_sprint_finishing_before_deadline,
                  [project_id, sprint_id, sprint_finish_date]).start()
    else:
        Timer(settings_for_push.SEC_PER_DAY,
              check_sprint_finishing_before_deadline,
              [project_id, sprint_id, sprint_finish_date]).start()
Esempio n. 2
0
def send_new_member_interview_notification(self, project_id, times):
    from threading import Timer
    settings_for_push.push_message_to_manager(
        project_id, "Your team has new members. Don't forget to ask them about"
        "progress in project at daily scrum meeting.",
        NotificationType.REVIEW_NEWCOMER)
    if times < settings_for_push.ADAPTATION_PERIOD_FOR_NEW_MEMBERS:
        Timer(settings_for_push.SEC_PER_DAY, self.send_new_member_interview_notification, [project_id, times + 1])\
            .start()
def push_on_overdue_sprint(new_sprint_id, project_id):
    # stories = UserStory.objects.filter(is_closed=False, milestone=new_sprint_id)
    is_milestone_closed = Milestone.objects.filter(
        id=new_sprint_id, project=project_id).first().closed
    # if stories.count() == 0:
    # TODO: set NOT here
    if is_milestone_closed:
        settings_for_push.push_message_to_manager(
            project_id, "You have an overdue sprint, check it!",
            settings_for_push.NotificationType.OVERDUE_SPRINT)
Esempio n. 4
0
def notificate_after_creating(project_id, owner_id):
    manager_id = settings_for_push.get_project_manager_id(project_id)

    # You don't need to get notification from yourself)
    if owner_id != manager_id:
        from taiga.users.models import User
        owner_name = User.objects.filter(id=owner_id).first().username
        project_name = Project.objects.filter(id=project_id).first().name
        settings_for_push.push_message_to_manager(
            project_id, "New user story was added to the project \"" +
            project_name + "\" by " + owner_name + ". Review it.",
            settings_for_push.NotificationType.NEW_USER_STORY_CREATED)
def push_on_blocked_tasks(project_id, project_name):
    opened_sprints = Milestone.objects.filter(closed=False, project=project_id)
    # findings blocked tasks in opened sprints
    is_blocked_tasks_in_sprints = False
    for sprint in opened_sprints:
        from taiga.projects.tasks.models import Task
        tasks = Task.objects.filter(milestone=sprint.id)
        for task in tasks:
            if task.is_blocked or task.status.name == "Needs Info":
                is_blocked_tasks_in_sprints = True
                break
    if is_blocked_tasks_in_sprints:
        settings_for_push.push_message_to_manager(
            project_id, "You have blocked tasks in project " + project_name,
            settings_for_push.NotificationType.BLOCKED_TASKS)
def push_on_high_priority(project_id):
    issues = Issue.objects.filter(project=project_id, assigned_to=None)
    unassigned_high_issues = 0
    for issue in issues:
        if issue.priority.name == "High":
            unassigned_high_issues = unassigned_high_issues + 1
    if unassigned_high_issues > 0:
        settings_for_push.push_message_to_manager(
            project_id, "You have " + str(unassigned_high_issues) +
            " unassigned issues with high priority."
            " Don't forget to assign it to somebody.", settings_for_push.
            NotificationType.HIGH_PRIORITY_ISSUE_WITHOUT_EXECUTOR)
    if issues.count() > 0:
        Timer(settings_for_push.SEC_PER_DAY, push_on_high_priority).start()
    else:
        notification_projects.remove(project_id)
def check_story_points(sprint_id, project_id, days_until_deadline):
    new_status_id = UserStoryStatus.objects.filter(project=project_id,
                                                   name="New").first().id
    all_story_points = 0
    stories = UserStory.objects.filter(is_closed=False, milestone=sprint_id)
    for story in stories:
        if story.status_id == new_status_id and story.get_total_points(
        ) is not None:
            all_story_points += story.get_total_points()
    if all_story_points > days_until_deadline:
        settings_for_push.push_message_to_manager(
            project_id,
            "Your team doesn't have time to complete all tasks before the sprint is over!"
            "You have to take actions!",
            settings_for_push.NotificationType.DEADLINE_IS_CLOSE)
    days_until_deadline -= 1
    if days_until_deadline > 0:
        Timer(15, check_story_points,
              [sprint_id, project_id, days_until_deadline]).start()
def check_users_activity(project_id, project_name):
    from taiga.projects.tasks.models import Task
    global in_progress_notification_projects

    memberships = Membership.objects.filter(project=project_id)
    in_progress_status = TaskStatus.objects.filter(project=project_id,
                                                   name="In progress")
    for membership in memberships:
        user = membership.user
        tasks = Task.objects.filter(project=project_id,
                                    assigned_to=user,
                                    status=in_progress_status)
        if tasks.count(
        ) == 0 and user.id != settings_for_push.get_project_manager_id(
                project_id):
            settings_for_push.push_message_to_manager(
                project_id, "User " + user.username + " doesn't have tasks in"
                " project " + project_name + ". Assign some tasks to him if "
                "it's possible.",
                settings_for_push.NotificationType.USER_WITHOUT_TASKS)