Ejemplo n.º 1
0
    def _update_trac_ticket(self, st_task):
        """
        Update the hours in trac based on the ST task
        """

        rv = { 'est_hours': None }
        
        if not self.trac_db:
            return rv

        trac_id = self._get_ticket_id(st_task.name)
        if not trac_id:
            return rv

        ticket = TracTicket(self.trac_db, trac_id)
        trac_hours = ticket.get_hours()
        if trac_hours == None:
            #
            # There's no totalhours. We probably aren't recording hours in
            # trac.  Perhaps the timingandestimationplugin could be installed.
            # In any case, just skip it.
            #
            return rv

        if abs(trac_hours - st_task.hours) >= 0.01:
            author = ticket.get_owner()
            ticket.set_hours(trac_hours, st_task.hours, author,
                             comment = "Updating ticket hours from !SlimTimer")
            self.trac_db.commit()

        rv['est_hours'] = ticket.get_est_hours()

        return rv