Exemple #1
0
    def dispatch(self):
        client = self.request.user.get_client()
        form = ProjectTimeForm(self.request.GET, client=client)

        GET = self.request.GET
        if len(
                GET
        ) == 1 and 'group_by_bugs' not in GET and 'group_by_user' not in GET:
            # ugly hack
            form.group_by_bugs.data = True
            form.group_by_user.data = True

        projects = form.projects.data
        if len(projects) != 1 or not projects[0].isdigit():
            raise HTTPBadRequest
        project = Project.query.get(projects[0])
        if not project:
            raise HTTPBadRequest

        if not form.validate():
            return dict(form=form, project=project)

        start_date, end_date = form.date_range.data
        without_bug_only = form.without_bug_only.data
        group_by = True, True, form.group_by_bugs.data, form.group_by_user.data

        LOG(u'Tickets project report %r - %r' % (start_date, end_date))

        uber_query = self._prepare_uber_query(
            start_date,
            end_date,
            projects,
            [],
            without_bug_only,
        )

        entries = uber_query.all()
        entries_sum = sum([e[-1] for e in entries])

        participation_of_workers = self._get_participation_of_workers(entries)

        tickets_id = ','.join([str(e[2]) for e in entries])
        trackers_id = ','.join([str(e[4].id) for e in entries])

        rows = Row.from_ordered_data(entries, group_by)

        return dict(
            rows=rows,
            entries_sum=entries_sum,
            form=form,
            project=project,
            participation_of_workers=participation_of_workers,
            participation_of_workers_sum=sum(
                [time[1] for time in participation_of_workers]),
            trackers_id=trackers_id,
            tickets_id=tickets_id,
        )
    def dispatch(self):
        sprint = self.v['sprint']
        bugs = self._fetch_bugs(sprint)
        sw = SprintWrapper(sprint, bugs, self.request)

        client = self.request.user.get_client()
        form = ProjectTimeForm(self.request.GET, client=client)

        if not self.request.GET.get('submited'):
            # ugly hack
            form.group_by_bugs.data = True
            form.group_by_user.data = True

        if not form.validate():
            return dict(form=form, sprint=sprint)

        group_by = True, True, form.group_by_bugs.data, form.group_by_user.data
        bigger_than = form.bigger_than.data
        ticket_choice = form.ticket_choice.data

        uber_query = self._prepare_uber_query_for_sprint(
            sprint, bugs, ticket_choice
        )
        entries = uber_query.all()

        if self.request.GET.get('excel'):
            from intranet3.lib.times import dump_entries_to_excel
            file, response = dump_entries_to_excel(
                entries, group_by, bigger_than
            )
            return response

        participation_of_workers = self._get_participation_of_workers(entries)

        tickets_id = ','.join([str(e[2]) for e in entries])
        trackers_id = ','.join([str(e[4].id) for e in entries])

        rows, entries_sum = HTMLRow.from_ordered_data(
            entries, group_by, bigger_than
        )

        return dict(
            rows=rows,
            entries_sum=entries_sum,
            form=form,
            info=sw.get_info(),
            participation_of_workers=participation_of_workers,
            participation_of_workers_sum=sum(
                [time[1] for time in participation_of_workers]
            ),
            trackers_id=trackers_id, tickets_id=tickets_id,
            sprint_tabs=sw.get_tabs()
        )
Exemple #3
0
    def dispatch(self):
        client = self.request.user.get_client()
        form = ProjectTimeForm(self.request.GET, client=client)

        GET = self.request.GET
        if len(GET) == 1 and 'group_by_bugs' not in GET and 'group_by_user' not in GET:
            # ugly hack
            form.group_by_bugs.data = True
            form.group_by_user.data = True

        projects = form.projects.data
        if len(projects) != 1 or not projects[0].isdigit():
            raise HTTPBadRequest
        project = Project.query.get(projects[0])
        if not project:
            raise HTTPBadRequest

        if not form.validate():
            return dict(form=form, project=project)

        start_date, end_date = form.date_range.data
        ticket_choice = form.ticket_choice.data
        bigger_than = form.bigger_than.data
        group_by = True, True, form.group_by_bugs.data, form.group_by_user.data

        LOG(u'Tickets project report %r - %r' % (start_date, end_date))

        uber_query = self._prepare_uber_query(
            start_date, end_date, projects, [], ticket_choice,
        )

        entries = uber_query.all()

        participation_of_workers = self._get_participation_of_workers(entries)

        tickets_id = ','.join([str(e[2]) for e in entries])
        trackers_id = ','.join([str(e[4].id) for e in entries])

        rows, entries_sum = HTMLRow.from_ordered_data(entries, group_by, bigger_than)

        return dict(
            rows=rows,
            entries_sum=entries_sum,
            form=form,
            project=project,
            participation_of_workers=participation_of_workers,
            participation_of_workers_sum=sum([time[1] for time in participation_of_workers]),
            trackers_id=trackers_id, tickets_id=tickets_id,
        )