Exemple #1
0
    def get(self, request, pslug):
        project = get_object_or_404(Project, slug=pslug)

        self.check_role(request.user, project, [
            ('project', 'view'),
            ('milestone', 'view'),
            ('userstory', 'view'),
        ])

        extras = project.get_extras()

        points_sum, extra_points_sum = 0, 0
        points_for_sprint = [points_sum]
        disponibility, extra_points = [], [0]

        sprints_queryset = project.milestones.order_by('created_date')

        now_position = None

        for i, sprint in enumerate(sprints_queryset, 1):
            usqs = sprint.user_stories.filter(status__in=['completed', 'closed'])
            points_sum += sum(iter_points(usqs))

            extra_points_user_stories = UserStory.objects.filter(
                created_date__gte=sprint.created_date,
                created_date__lte=sprint.estimated_finish
            )

            extra_points_user_stories_shareds = extra_points_user_stories\
                .filter(client_requirement=True, team_requirement=True)
            extra_points_sum += sum(x/2.0 for x in iter_points(extra_points_user_stories_shareds))


            extra_points_user_stories = extra_points_user_stories\
                .filter(client_requirement=True, team_requirement=False)
            extra_points_sum += sum(iter_points(extra_points_user_stories))
            extra_points.append(extra_points_sum)

            points_for_sprint.append(points_sum)
            disponibility.append(sprint.disponibility)

            if timezone.now().date() <= sprint.estimated_finish and timezone.now().date() >= sprint.estimated_start:
                end_days = (sprint.estimated_finish-sprint.estimated_start).days
                now_days = (timezone.now().date()-sprint.estimated_start).days
                now_position = (float(now_days)/float(end_days))+i

        context = {
            'points_for_sprint': points_for_sprint,
            'disponibility': disponibility,
            'sprints_number': extras.sprints,
            'extra_points': extra_points,
            'now_position': now_position,
            #old
            #'total_points': sum(iter_points(project.user_stories.all())),
            'total_points': sum(iter_points(project.user_stories\
                .exclude(Q(client_requirement=True) | Q(team_requirement=True)))),
        }

        return self.render_to_ok(context)
Exemple #2
0
    def total_points(self):
        """
        Get total story points for this milestone.
        """

        total = sum(iter_points(self.user_stories.all()))
        return "{0:.1f}".format(total)
Exemple #3
0
    def completed_points(self):
        """
        Get a total of completed points.
        """

        queryset = self.user_stories.filter(status__in=settings.CLOSED_STATUSES)
        total = sum(iter_points(queryset))
        return "{0:.1f}".format(total)
Exemple #4
0
    def completed_points(self):
        """
        Get a total of completed points.
        """

        queryset = self.user_stories.filter(status__in=SCRUM_STATES.get_finished_us_states())
        total = sum(iter_points(queryset))
        return "{0:.1f}".format(total)
Exemple #5
0
    def calculate_stats(self, unassigned, assigned, completed):
        unassigned_points = sum(iter_points(unassigned))
        assigned_points = sum(iter_points(assigned))
        completed_points = sum(iter_points(completed))

        total_points = unassigned_points + assigned_points

        try:
            percentage_assigned = (assigned_points * 100) / total_points
        except ZeroDivisionError:
            percentage_assigned = 0

        try:
            percentage_completed = (completed_points * 100) / total_points
        except ZeroDivisionError:
            percentage_completed = 0

        return {
            'unassigned_points': unassigned_points,
            'assigned_points': assigned_points,
            'total_points': total_points,
            'percentage_completed': "{0:.2f}".format(percentage_completed),
            'percentage_assigned': "{0:.2f}".format(percentage_assigned),
        }
Exemple #6
0
    def get(self, request, pslug):
        project = get_object_or_404(models.Project, slug=pslug)

        self.check_role(request.user, project, [
            ('project', 'view'),
            ('milestone', 'view'),
            ('userstory', 'view'),
        ])

        extras = project.get_extras()

        points_sum = 0
        points_for_sprint = [points_sum]
        disponibility = []
        extra_points = [0]
        extra_points_sum = 0
        extra_points_team = [0]
        extra_points_team_sum = 0

        sprints_queryset = project.milestones.order_by('created_date')
        for i, sprint in enumerate(sprints_queryset, 1):
            usqs = sprint.user_stories.filter(status__in=['completed', 'closed'])
            points_sum += sum(iter_points(usqs))

            extra_points_user_stories = models.UserStory.objects.filter(
                created_date__gt=sprint.created_date,
                created_date__lt=sprint.estimated_finish
            )

            extra_points_user_stories_shareds = extra_points_user_stories\
                .filter(client_requirement=True, team_requirement=True)
            extra_points_sum += sum(x/2.0 for x in iter_points(extra_points_user_stories_shareds))

            extra_points_user_stories = extra_points_user_stories\
                .filter(client_requirement=True, team_requirement=False)
            extra_points_sum += sum(iter_points(extra_points_user_stories))
            extra_points.append(extra_points_sum)

            extra_points_team_user_stories = models.UserStory.objects.filter(
                created_date__gt=sprint.created_date,
                created_date__lt=sprint.estimated_finish
            )

            extra_points_team_user_stories_shareds = extra_points_team_user_stories\
                .filter(team_requirement=True, client_requirement=True)

            extra_points_team_sum += sum(x/2.0 for x in iter_points(extra_points_team_user_stories_shareds))

            extra_points_team_user_stories = extra_points_team_user_stories\
                .filter(team_requirement=True, client_requirement=False)

            extra_points_team_sum += sum(iter_points(extra_points_team_user_stories))
            extra_points_team.append(extra_points_team_sum)

            points_for_sprint.append(points_sum)

        total_points = sum(iter_points(project.user_stories.all()))

        sprints = []
        sprints.append(points_for_sprint)
        sprints.append(extra_points_team)
        sprints.append(extra_points)

        context = {
            'sprints': sprints,
            #'total_points': sum(iter_points(project.user_stories.all())),
            'total_points': sum(iter_points(project.user_stories\
                .exclude(Q(client_requirement=True) | Q(team_requirement=True)))),
            'total_sprints': extras.sprints,
        }

        return self.render_to_ok(context)