Ejemplo n.º 1
0
    def invoke(self, message, warnings):
        """make a new ticket on receiving email"""

        # local warnings
        _warnings = []

        # get the ticket reporter
        reporter = self.reporter(message)

        # get the description and attachments
        description, attachments = get_description_and_attachments(message)
        if description is None:
            description = ''
        description = description.strip()

        # get the ticket fields
        fields = self.fields(message, _warnings, reporter=reporter, description=description)

        # inset items from email
        ticket = Ticket(self.env)
        for key, value in fields.items():
            ticket.values[key] = value

        # fill in default values
        for field in ticket.fields:
            name = field['name']
            if name not in fields:
                option = 'ticket_field.%s' % name
                if self.env.config.has_option('mail', option):
                    ticket.values[name] = self.env.config.get('mail', option)
                else:
                    try:
                        value = ticket.get_value_or_default(name) or ''
                    except AttributeError: # BBB
                        value = ''
                    if value is not None:
                        ticket.values[name] = value

        # create the ticket
        ticket.insert()

        # add attachments to the ticket
        add_attachments(self.env, ticket, attachments)

        # do whatever post-processing is necessary
        self.post_process(ticket)

        # add local warnings
        if _warnings:
            warning = """A ticket has been created but there is a problem:\n\n%s\n\nPlease edit your ticket by going here: %s""" % ('\n\n'.join([' - %s' % warning for warning in _warnings]), self.env.abs_href('ticket', ticket.id))
            warnings.append(warning)
Ejemplo n.º 2
0
    def invoke(self, message, warnings):
        """reply to a ticket"""
        ticket = self.ticket(message)
        reporter = self.reporter(message)

        # get the description and attachments
        description, attachments = get_description_and_attachments(message)
        if not description:
            warnings.append("Seems to be a reply to %s but I couldn't find a comment")
            return message
        
        # save changes to the ticket
        ticket.save_changes(reporter, description)

        # ticket notification
        tn = TicketNotifyEmail(self.env)
        tn.notify(ticket, newticket=0, modtime=ticket.time_changed)