コード例 #1
0
ファイル: sprint.py プロジェクト: woliveira0101/intranet-open
    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()
        )
コード例 #2
0
ファイル: client.py プロジェクト: adamgr/intranet
    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,
        )
コード例 #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,
        )
コード例 #4
0
ファイル: tickets.py プロジェクト: adamgr/intranet
    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
        bigger_than = form.bigger_than.data
        ticket_choice = form.ticket_choice.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, 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,
            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,
        )
コード例 #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]
        bug_id = self.request.GET.get('bug_id')
        users = form.users.data
        bigger_than = form.bigger_than.data
        ticket_choice = form.ticket_choice.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, ticket_choice, bug_id)

        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,
            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,
            str_date=self._sprint_daterange(start_date, end_date),
        )