Guest User

Untitled

a guest
Jan 5th, 2016
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- worklog.orig/manager.py     2016-01-05 10:40:19.621308861 +0100
  2. +++ worklog/manager.py  2016-01-05 11:57:38.973366636 +0100
  3. @@ -7,7 +7,10 @@
  4.  from trac.ticket import Ticket
  5.  from trac.util.datefmt import format_date, format_time, pretty_timedelta, \
  6.                                to_datetime
  7. -
  8. +try:
  9. +    from trachours.hours import TracHoursPlugin
  10. +except ImportError:
  11. +    pass
  12.  
  13.  class WorkLogManager:
  14.      env = None
  15. @@ -172,6 +175,7 @@
  16.  
  17.          message = ''
  18.          hours = '0.0'
  19. +        seconds = 0;
  20.  
  21.          # Leave a comment if the user has configured this or if they have entered
  22.          # a work log comment.
  23. @@ -179,7 +183,8 @@
  24.              round_delta = float(self.config.getint('worklog', 'roundup') or 1)
  25.  
  26.              # Get the delta in minutes
  27. -            delta = float(int(stoptime) - int(active['starttime'])) / float(60)
  28. +            seconds = float(int(stoptime) - int(active['starttime']))
  29. +            delta = seconds / float(60)
  30.  
  31.              # Round up if needed
  32.              delta = int(round((delta / round_delta) + float(0.5))) * int(round_delta)
  33. @@ -189,7 +194,9 @@
  34.              hours = str(float(int(100 * float(delta) / 60) / 100.0))
  35.  
  36.          if plughrs:
  37. -            message = 'Hours recorded automatically by the worklog plugin. %s hours' % hours
  38. +            hoursmessage = 'Hours recorded automatically by the worklog plugin. %s hours' % hours
  39. +            ticket = Ticket(self.env, active['ticket'])
  40. +            TracHoursPlugin(self.env).add_ticket_hours(ticket.id, self.authname, seconds, comments=hoursmessage)
  41.          elif self.config.getbool('worklog', 'comment') or comment:
  42.              started = datetime.fromtimestamp(active['starttime'])
  43.              finished = datetime.fromtimestamp(stoptime)
  44. @@ -200,7 +207,7 @@
  45.          if comment:
  46.              message += "\n[[BR]]\n" + comment
  47.  
  48. -        if plugtne or plughrs:
  49. +        if plugtne:
  50.              if not message:
  51.                  message = 'Hours recorded automatically by the worklog plugin.'
RAW Paste Data