Exemplo n.º 1
0
    def add_hours_by_comment(self, comment, ticket, worker):
        """
        add hours to a ticket via a comment string
        * comment : the comment string
        * ticket : the id of the ticket
        * worker : who worked the hours
        """
        trachours = TracHoursPlugin(self.env)
        for match in re.finditer(self.hours_regex, comment):
            hours = match.groups()[0]
            if ':' in hours:
                hours, minutes = hours.split(':')
                seconds = 3600.0 * float(hours) + 60.0 * float(minutes)
            else:
                seconds = 3600.0 * float(hours)
            _comment = re.sub('\[/hours/[0-9]+ ' + self.hours_regex + '\]',
                              match.group(), comment)
            trachours.add_ticket_hours(ticket,
                                       worker,
                                       seconds,
                                       comments=_comment)

        for match in re.finditer(self.singular_hour_regex, comment):
            _comment = re.sub('\[/hours/[0-9]+ 1 hour\]', '1 hour', comment)
            trachours.add_ticket_hours(ticket,
                                       worker,
                                       3600.0,
                                       comments=_comment)
Exemplo n.º 2
0
    def add_hours_by_comment(self, comment, ticket, worker):
        """
        add hours to a ticket via a comment string
        * comment : the comment string
        * ticket : the id of the ticket
        * worker : who worked the hours
        """
        trachours = TracHoursPlugin(self.env)
        for match in re.finditer(self.hours_regex, comment):
            hours = match.groups()[0]
            if ':' in hours:
                hours, minutes = hours.split(':')
                seconds = 3600.0*float(hours) + 60.0*float(minutes)
            else:
                seconds = 3600.0*float(hours)
            _comment = re.sub('\[/hours/[0-9]+ ' + self.hours_regex + '\]', match.group(), comment)
            trachours.add_ticket_hours(ticket, worker, seconds, comments=_comment)

        for match in re.finditer(self.singular_hour_regex, comment):
            _comment = re.sub('\[/hours/[0-9]+ 1 hour\]', '1 hour', comment)
            trachours.add_ticket_hours(ticket, worker, 3600.0, comments=_comment)