Example #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,
        )
Example #2
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,
        )
Example #3
0
    def dispatch(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(self.request.GET, client=client)

        if not self.request.GET or not form.validate():
            return dict(form=form)

        start_date, end_date = form.date_range.data
        projects = form.projects.data

        if not projects:
            projects = [p[0] for p in form.projects.choices]

        users = form.users.data
        without_bug_only = form.without_bug_only.data
        group_by = (form.group_by_client.data, form.group_by_project.data,
                    form.group_by_bugs.data, form.group_by_user.data)

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

        uber_query = self._prepare_uber_query(
            start_date,
            end_date,
            projects,
            users,
            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,
            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,
        )
Example #4
0
    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

        uber_query = self._prepare_uber_query_for_sprint(sprint, bugs)
        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)
            return response

        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,
            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,
        )
Example #5
0
    def dispatch(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(self.request.GET, client=client)

        if not self.request.GET or not form.validate():
            return dict(form=form)

        start_date, end_date = form.date_range.data
        projects = form.projects.data

        if not projects:
            projects = [p[0] for p in form.projects.choices]

        users = form.users.data
        without_bug_only = form.without_bug_only.data
        group_by = (
            form.group_by_client.data,
            form.group_by_project.data,
            form.group_by_bugs.data,
            form.group_by_user.data,
        )

        LOG(u"Tickets report %r - %r - %r" % (start_date, end_date, projects))

        uber_query = self._prepare_uber_query(start_date, end_date, projects, users, 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,
            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,
        )
Example #6
0
    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

        uber_query = self._prepare_uber_query_for_sprint(sprint, bugs)
        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)
            return response

        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,
            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,
        )