Exemplo n.º 1
0
    def save(self, *args, **kwargs):
        "Set Resolution if selected"
        instance = super(TicketRecordForm, self).save(*args, **kwargs)
        ticket = self.ticket
        if 'resolution' in self.cleaned_data and self.cleaned_data['resolution']:
            ticket.resolution = self.cleaned_data['body']
            ticket.save()
        
        # Send update if notify clicked
        if 'notify' in self.cleaned_data and self.cleaned_data['notify'] and ticket.caller:
            toaddr = ticket.caller.get_email()
            if ticket.message or toaddr:
                reply = Message()
                reply.author = instance.sender
                reply.body = instance.body
                reply.auto_notify = False
                if ticket.message:
                    reply.stream = ticket.message.stream
                    reply.reply_to = ticket.message
                else:
                    reply.stream = ticket.queue.message_stream if ticket.queue else None
                    reply.title = "[#%s] %s" % (ticket.reference, ticket.name)
                reply.save()
                if not ticket.message:
                    ticket.message = reply
                reply.recipients.add(ticket.caller)
                email = EmailMessage(reply)
                email.send_email()

        return instance
Exemplo n.º 2
0
 def send_email(self):
     "Send email"
     email = EmailMessage(self)
     if self.stream and self.stream.outgoing_server_name:
         email.send_email()