Beispiel #1
0
    def getEntriesForTodoItem(self, todo_item_id):
        """Get all entries (for a todo item)
        
        REST: GET /todo_items/#{todo_item_id}/time_entries.xml
        
        Returns all time entries associated with the given todo item, in
        descending order by date. 
        
        Response:

            <time-entries type="array">
                <time-entry>
                    ...
                </time-entry>
                    ...
            </time-entries>
        """
        # ensure that we got numerical id
        assert isinstance(todo_item_id, int)
       
        path = '/todo_items/%d/time_entries.xml' % todo_item_id
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Todo item with %d id is not found!' % \
                 todo_item_id
        
        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        time_entries = []
        for data in rootElement.getElementsByTagName('time-entry'):
            time_entries.append(TimeEntry.load(data))
        return time_entries
Beispiel #2
0
    def getEntriesForTodoItem(self, todo_item_id):
        """Get all entries (for a todo item)
        
        REST: GET /todo_items/#{todo_item_id}/time_entries.xml
        
        Returns all time entries associated with the given todo item, in
        descending order by date. 
        
        Response:

            <time-entries type="array">
                <time-entry>
                    ...
                </time-entry>
                    ...
            </time-entries>
        """
        # ensure that we got numerical id
        assert isinstance(todo_item_id, int)

        path = '/todo_items/%d/time_entries.xml' % todo_item_id
        response = self.get(path)
        if response.status == 404:
            raise NotFoundError, 'Todo item with %d id is not found!' % \
                 todo_item_id

        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        time_entries = []
        for data in rootElement.getElementsByTagName('time-entry'):
            time_entries.append(TimeEntry.load(data))
        return time_entries
Beispiel #3
0
    def getEntriesReport(self,
                         _from,
                         _to,
                         subject_id=None,
                         todo_item_id=None,
                         filter_project_id=None,
                         filter_company_id=None):
        """Get time report

        REST: GET /time_entries/report.xml

        Returns the set of time entries that match the given criteria.

        This action accepts the following query parameters: from, to,
        subject_id, todo_item_id, filter_project_id, and filter_company_id. Both
        from and to should be dates in YYYYMMDD format, and can be used to
        restrict the result to a particular date range. (No more than 6 months'
        worth of entries may be returned in a single query, though). The
        subject_id parameter lets you constrain the result to a single person's
        time entries. todo_item_id restricts the result to only those entries
        relating to the given todo item. filter_project_id restricts the entries
        to those for the given project, and filter_company_id restricts the
        entries to those for the given company.

        Response:

            <time-entries type="array">
              <time-entry>
                ...
              </time-entry>
              ...
            </time-entries>
        """
        # ensure that we got numerical ids
        query = ['from=%s' % _from, 'to=%s' % _to]
        if subject_id:
            assert isinstance(subject_id, int)
            query.append('subject_id=%d' % subject_id)
        if todo_item_id:
            assert isinstance(todo_item_id, int)
            query.append('todo_item_id=%d' % todo_item_id)
        if filter_project_id:
            assert isinstance(filter_project_id, int)
            query.append('filter_project_id=%d' % filter_project_id)
        if filter_company_id:
            assert isinstance(filter_company_id, int)
            query.append('filter_company_id=%d' % filter_company_id)

        path = '/time_entries/report.xml?%s' % '&'.join(query)
        response = self.get(path)
        if response.status != 200:
            return self.getErrors(response.contents)

        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        time_entries = []
        for data in rootElement.getElementsByTagName('time-entry'):
            time_entries.append(TimeEntry.load(data))
        return time_entries
Beispiel #4
0
    def getEntriesReport(self, _from, _to, subject_id=None, todo_item_id=None,
                         filter_project_id=None, filter_company_id=None):
        """Get time report

        REST: GET /time_entries/report.xml

        Returns the set of time entries that match the given criteria.

        This action accepts the following query parameters: from, to,
        subject_id, todo_item_id, filter_project_id, and filter_company_id. Both
        from and to should be dates in YYYYMMDD format, and can be used to
        restrict the result to a particular date range. (No more than 6 months'
        worth of entries may be returned in a single query, though). The
        subject_id parameter lets you constrain the result to a single person's
        time entries. todo_item_id restricts the result to only those entries
        relating to the given todo item. filter_project_id restricts the entries
        to those for the given project, and filter_company_id restricts the
        entries to those for the given company.

        Response:

            <time-entries type="array">
              <time-entry>
                ...
              </time-entry>
              ...
            </time-entries>
        """
        # ensure that we got numerical ids
        query = ['from=%s' % _from, 'to=%s' % _to]
        if subject_id:
            assert isinstance(subject_id, int)
            query.append('subject_id=%d' % subject_id)
        if todo_item_id:
            assert isinstance(todo_item_id, int)
            query.append('todo_item_id=%d' % todo_item_id)
        if filter_project_id:
            assert isinstance(filter_project_id, int)
            query.append('filter_project_id=%d' % filter_project_id)
        if filter_company_id:
            assert isinstance(filter_company_id, int)
            query.append('filter_company_id=%d' % filter_company_id)

        path = '/time_entries/report.xml?%s' % '&'.join(query)
        response = self.get(path)
        if response.status != 200:
            return self.getErrors(response.contents)

        rootElement = self.fromXML(response.contents)
        # TODO: use special Array attribute
        time_entries = []
        for data in rootElement.getElementsByTagName('time-entry'):
            time_entries.append(TimeEntry.load(data))
        return time_entries