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_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'