From: <ke...@us...> - 2006-06-26 16:25:17
|
Revision: 3247 Author: kevca Date: 2006-06-26 09:25:12 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/mailmanager/?rev=3247&view=rev Log Message: ----------- Fixes for No way to mix citation text and messages (#1512826) Modified Paths: -------------- MailManager/branches/RELENG_2_1/Extensions/TicketPluggableBrain.py Modified: MailManager/branches/RELENG_2_1/Extensions/TicketPluggableBrain.py =================================================================== --- MailManager/branches/RELENG_2_1/Extensions/TicketPluggableBrain.py 2006-06-26 14:34:13 UTC (rev 3246) +++ MailManager/branches/RELENG_2_1/Extensions/TicketPluggableBrain.py 2006-06-26 16:25:12 UTC (rev 3247) @@ -1024,23 +1024,12 @@ # Obtain the template details, deailing with the cite_last # method appropriately if template_name == 'cite_last': - # Find the last actual message - msgs = self.sql.listMessages(sqv_ticket_id=self.id) - # Skip over any notes - for position in range(1,len(msgs)+1): - zmsg = msgs[-position] - if not zmsg.msg_to == '': break - # Remove the signature and split the plain text body per - # line, start with > for quote chars. Note that we don't - # currently quote HTML, but that would be a nice addition - # in the future. - cite = sig_remover.sub('', zmsg.body) - body = ''.join(['> %s' % line for line - in cite.splitlines(1)]) + body = self._citeLastMessage() template_is_html = 0 else: template = self._getTemplate(template_name) - body = template['body'] + # Replace template paramaters + body = self.replaceTemplateParameters(template['body']) template_is_html = template['html'] # Is this an HTML template? Check the settings flag @@ -1062,6 +1051,43 @@ return self.index_html(REQUEST) + security.declareProtected('MailManager Manage Tickets', '_citeLastMessage') + def _citeLastMessage(self): + """ Obtain a citation of the last message + + Returns a utf-8 encoded string + """ + + # Find the last actual message + msgs = self.sql.listMessages(sqv_ticket_id=self.id) + # Skip over any notes + for position in range(1,len(msgs)+1): + zmsg = msgs[-position] + if not zmsg.msg_to == '': break + # Remove the signature and split the plain text body per + # line, start with > for quote chars. Note that we don't + # currently quote HTML, but that would be a nice addition + # in the future. + cite = sig_remover.sub('', zmsg.body) + body = ''.join(['> %s' % line.encode('utf-8') for line + in cite.splitlines(1)]) + return body + + security.declareProtected('MailManager Manage Tickets', 'replaceTemplateParameters') + def replaceTemplateParameters(self, template_body): + """ Replace the metavariables in the templates with the right content + + Currently supported is: + + %T - ticket id + %L - cite last message + """ + # Replace any paramaters in this code + template_body = template_body.replace('%T', str(self.id)) + template_body = template_body.replace('%L', self._citeLastMessage()) + return template_body + + security.declareProtected('MailManager Manage Tickets', 'renderHTML') def renderHTML(self, msg_id): """ Temporary method to render a message as an iframe """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |