From: Andrew V. <av...@us...> - 2005-05-18 21:03:44
|
Update of /cvsroot/mailmanager/mailmanager/Extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1657/Extensions Modified Files: Tag: RELENG_2_0 TicketPluggableBrain.py Log Message: Cite last message and templates now work when replying to a ticket #1204267 Note that as the templates system still uses the ZODB I was able to implement this by just copying over the code from MM1.1 with fairly minor modifications. Index: TicketPluggableBrain.py =================================================================== RCS file: /cvsroot/mailmanager/mailmanager/Extensions/TicketPluggableBrain.py,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -u -d -r1.2.2.3 -r1.2.2.4 --- TicketPluggableBrain.py 18 May 2005 19:34:36 -0000 1.2.2.3 +++ TicketPluggableBrain.py 18 May 2005 21:03:34 -0000 1.2.2.4 @@ -338,8 +338,43 @@ also be in HTML if the account signature is in HTML, but in this case there is no format select box. """ + # No change of body, possibly a change of format. + if template_name.endswith('_plain'): + template_name = template_name[:-6] + template_is_html = 0 + body_was_html = 0 + elif template_name.endswith('_html'): + template_name = template_name[:-5] + template_is_html = self._getTemplate(template_name).get('html', 0) + body_was_html = 1 + # A new choice of template. + else: + if template_name == 'cite_last': + zmsg = self.sql.listMessages(ticket_id=self.id)[-1] + body = ''.join(['> %s' % line for line + in zmsg.body.splitlines(1)]) + template_is_html = 0 + else: + template = self._getTemplate(template_name) + body = template.get('body', '') + template_is_html = template.get('html', 0) + body_was_html = template_is_html + # Determine format of message body and convert if required. + body_is_html = body_is_html or template_is_html or self.HTMLRequired() + if body_is_html and not body_was_html: + body = self._makeHTML(body) + if not body_is_html and body_was_html: + body = html2text(body, ('script', 'noscript', 'style')) + # Reset template_name. + template_name = '%s_%s' % (template_name, + body_is_html and 'html' or 'plain') return template_name, body_is_html, body + security.declarePrivate('_getTemplate') + def _getTemplate(self, template_name): + # XXX reply_templates acquired. + return self.reply_templates.get(template_name, {}) + security.declareProtected('MailManager Manage Tickets', 'HTMLRequired') def HTMLRequired(self): """Determine whether the message must be composed in HTML. @@ -348,7 +383,8 @@ in use. Once HTML user signatures are added they will also force HTML composition. """ - return False + account = self.sql.listAccounts(email=self.account_id)[0] + return account.signature and account.html_signature security.declareProtected('MailManager Manage Tickets', 'addAttachment') def addAttachment(self, REQUEST, RESPONSE, standard_attach = None, |