예제 #1
0
    def get(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(formdata=self.request.GET, client=client)
        if not form.validate():
            return render('time/tickets_report/projects_report.html',
                          dict(form=form))

        query = DBSession.query
        start_date, end_date = form.date_range.data
        projects = form.projects.data
        users = form.users.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)
        bigger_than = form.bigger_than.data

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

        uber_query = query(Client, Project, TimeEntry.ticket_id, User, Tracker,
                           TimeEntry.description, TimeEntry.date,
                           TimeEntry.time)
        uber_query = uber_query.filter(TimeEntry.user_id==User.id)\
                               .filter(TimeEntry.project_id==Project.id)\
                               .filter(Project.tracker_id==Tracker.id)\
                               .filter(Project.client_id==Client.id)

        if projects:
            uber_query = uber_query.filter(TimeEntry.project_id.in_(projects))

        uber_query = uber_query.filter(TimeEntry.date>=start_date)\
                               .filter(TimeEntry.date<=end_date)\
                               .filter(TimeEntry.deleted==False)

        if ticket_choice == 'without_bug_only':
            uber_query = uber_query.filter(TimeEntry.ticket_id == '')
        elif ticket_choice == 'meetings_only':
            meeting_ids = [
                t['value'] for t in TimeEntryForm.PREDEFINED_TICKET_IDS
            ]
            uber_query = uber_query.filter(
                TimeEntry.ticket_id.in_(meeting_ids))

        if users:
            uber_query = uber_query.filter(User.id.in_(users))

        uber_query = uber_query.order_by(Client.name, Project.name,
                                         TimeEntry.ticket_id, User.name)
        entries = uber_query.all()
        file, response = dump_entries_to_excel(entries, group_by, bigger_than)

        return response
예제 #2
0
    def get(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(formdata=self.request.GET, client=client)
        if not form.validate():
            return render('time/tickets_report/projects_report.html', dict(form=form))

        query = DBSession.query
        start_date, end_date = form.date_range.data
        projects = form.projects.data
        users = form.users.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
        )
        bigger_than = form.bigger_than.data

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

        uber_query = query(Client, Project, TimeEntry.ticket_id, User, Tracker, TimeEntry.description, TimeEntry.date, TimeEntry.time)
        uber_query = uber_query.filter(TimeEntry.user_id==User.id)\
                               .filter(TimeEntry.project_id==Project.id)\
                               .filter(Project.tracker_id==Tracker.id)\
                               .filter(Project.client_id==Client.id)

        if projects:
            uber_query = uber_query.filter(TimeEntry.project_id.in_(projects))

        uber_query = uber_query.filter(TimeEntry.date>=start_date)\
                               .filter(TimeEntry.date<=end_date)\
                               .filter(TimeEntry.deleted==False)

        if ticket_choice == 'without_bug_only':
            uber_query = uber_query.filter(TimeEntry.ticket_id=='')
        elif ticket_choice == 'meetings_only':
            meeting_ids = [t['value'] for t in TimeEntryForm.PREDEFINED_TICKET_IDS]
            uber_query = uber_query.filter(TimeEntry.ticket_id.in_(meeting_ids))

        if users:
            uber_query = uber_query.filter(User.id.in_(users))

        uber_query = uber_query.order_by(Client.name, Project.name, TimeEntry.ticket_id, User.name)
        entries = uber_query.all()
        file, response = dump_entries_to_excel(entries, group_by, bigger_than)

        return response
예제 #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,
        )
예제 #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),
        )
예제 #6
0
    def get(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(formdata=self.request.GET, client=client)
        if not form.validate():
            return render("time/tickets_report/projects_report.html", dict(form=form))

        query = self.session.query
        start_date, end_date = form.date_range.data
        projects = form.projects.data
        users = form.users.data
        without_bug_only = form.without_bug_only.data

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

        uber_query = query(
            Client, Project, TimeEntry.ticket_id, User, Tracker, TimeEntry.description, TimeEntry.date, TimeEntry.time
        )
        uber_query = (
            uber_query.filter(TimeEntry.user_id == User.id)
            .filter(TimeEntry.project_id == Project.id)
            .filter(Project.tracker_id == Tracker.id)
            .filter(Project.client_id == Client.id)
        )

        uber_query = (
            uber_query.filter(TimeEntry.project_id.in_(projects))
            .filter(TimeEntry.date >= start_date)
            .filter(TimeEntry.date <= end_date)
            .filter(TimeEntry.deleted == False)
        )
        if without_bug_only:
            uber_query = uber_query.filter(TimeEntry.ticket_id == None)

        if users:
            uber_query = uber_query.filter(User.id.in_(users))

        uber_query = uber_query.order_by(Client.name, Project.name, TimeEntry.ticket_id, User.name)
        entries = uber_query.all()
        file, response = dump_entries_to_excel(entries)

        return response
예제 #7
0
    def get(self):
        client = self.request.user.get_client()
        form = ProjectsTimeForm(formdata=self.request.GET, client=client)
        if not form.validate():
            return render('time/tickets_report/projects_report.html',
                          dict(form=form))

        query = self.session.query
        start_date, end_date = form.date_range.data
        projects = form.projects.data
        users = form.users.data
        without_bug_only = form.without_bug_only.data

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

        uber_query = query(Client, Project, TimeEntry.ticket_id, User, Tracker,
                           TimeEntry.description, TimeEntry.date,
                           TimeEntry.time)
        uber_query = uber_query.filter(TimeEntry.user_id==User.id)\
                               .filter(TimeEntry.project_id==Project.id)\
                               .filter(Project.tracker_id==Tracker.id)\
                               .filter(Project.client_id==Client.id)

        uber_query = uber_query.filter(TimeEntry.project_id.in_(projects))\
                               .filter(TimeEntry.date>=start_date)\
                               .filter(TimeEntry.date<=end_date)\
                               .filter(TimeEntry.deleted==False)
        if without_bug_only:
            uber_query = uber_query.filter(TimeEntry.ticket_id == None)

        if users:
            uber_query = uber_query.filter(User.id.in_(users))

        uber_query = uber_query.order_by(Client.name, Project.name,
                                         TimeEntry.ticket_id, User.name)
        entries = uber_query.all()
        file, response = dump_entries_to_excel(entries)

        return response