def _update_ticket(self, ticket, st_task, author): """ Update the trac ticket based on the SlimTimer task. """ # # Check if anything changed # id_changed = ticket.values.has_key('slimtimer_id') and \ (getint(ticket['slimtimer_id']) < 1 or \ getint(ticket['slimtimer_id']) != st_task.id) hours_changed = ticket.values.has_key('totalhours') and \ getfloat(ticket['totalhours']) != st_task.hours if not id_changed and not hours_changed: return # # Get some common information for storing the changes # db = self.env.get_db_cnx() cl = ticket.get_changelog() if cl: most_recent_change = cl[-1]; change_time = most_recent_change[0] else: change_time = ticket.time_created raw_ticket = TracTicket(db, ticket.id) # # Apply ID changes # if id_changed: prev_st_id = ticket.values.get('slimtimer_id') new_st_id = st_task.id raw_ticket.set_st_id(prev_st_id, new_st_id, author, change_time) # # Apply hours changes # if hours_changed: prev_totalhours = ticket.values.get('totalhours') new_totalhours = st_task.hours raw_ticket.set_hours(prev_totalhours, new_totalhours, author, change_time) # # Update the ticket object too in case another ticket change # handler is called after us # ticket['totalhours'] = str(st_task.hours) ticket['hours'] = '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
def _update_ticket(self, ticket, st_task, author): """ Update the trac ticket based on the SlimTimer task. """ # # Check if anything changed # id_changed = ticket.values.has_key('slimtimer_id') and \ (getint(ticket['slimtimer_id']) < 1 or \ getint(ticket['slimtimer_id']) != st_task.id) hours_changed = ticket.values.has_key('totalhours') and \ getfloat(ticket['totalhours']) != st_task.hours if not id_changed and not hours_changed: return # # Get some common information for storing the changes # db = self.env.get_db_cnx() cl = ticket.get_changelog() if cl: most_recent_change = cl[-1] change_time = most_recent_change[0] else: change_time = ticket.time_created raw_ticket = TracTicket(db, ticket.id) # # Apply ID changes # if id_changed: prev_st_id = ticket.values.get('slimtimer_id') new_st_id = st_task.id raw_ticket.set_st_id(prev_st_id, new_st_id, author, change_time) # # Apply hours changes # if hours_changed: prev_totalhours = ticket.values.get('totalhours') new_totalhours = st_task.hours raw_ticket.set_hours(prev_totalhours, new_totalhours, author, change_time) # # Update the ticket object too in case another ticket change # handler is called after us # ticket['totalhours'] = str(st_task.hours) ticket['hours'] = '0'