From de93e95214f6540353bd49aacc4ee9316971088f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Fri, 13 Jun 2008 09:37:36 +0000 Subject: [PATCH] make title_or_id work for ingested email documents. (also fix docstrings for EmailDocument.getTitle and EmailDocument.getStartDate) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21569 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/EmailDocument.py | 9 +++++++-- product/ERP5/tests/testCRM.py | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/product/ERP5/Document/EmailDocument.py b/product/ERP5/Document/EmailDocument.py index 97df20f0cd..38a91e183b 100644 --- a/product/ERP5/Document/EmailDocument.py +++ b/product/ERP5/Document/EmailDocument.py @@ -215,7 +215,7 @@ class EmailDocument(File, TextDocument): security.declareProtected(Permissions.AccessContentsInformation, 'getTitle') def getTitle(self, default=_MARKER): """ - Returns the title + Returns the title from the mail subject """ if not self.hasFile(): # Return the standard text content if no file was provided @@ -224,11 +224,16 @@ class EmailDocument(File, TextDocument): else: return self._baseGetTitle(default) return self.getContentInformation().get('Subject', '') + + def title_or_id(self): + """Return the title if it is not blank and the id otherwise. + """ + return self.getTitleOrId() security.declareProtected(Permissions.AccessContentsInformation, 'getStartDate') def getStartDate(self, default=_MARKER): """ - Returns the title + Returns the date from the mail date """ if not self.hasFile(): # Return the standard start date if no file was provided diff --git a/product/ERP5/tests/testCRM.py b/product/ERP5/tests/testCRM.py index b1010836ce..314e21efdd 100644 --- a/product/ERP5/tests/testCRM.py +++ b/product/ERP5/tests/testCRM.py @@ -370,6 +370,8 @@ class TestCRMMailIngestion(ERP5TypeTestCase): # tite is found automatically, based on the Subject: header in the mail event = self._ingestMail('simple') self.assertEquals('Simple Mail Test', event.getTitle()) + self.assertEquals('Simple Mail Test', event.getTitleOrId()) + self.assertEquals('Simple Mail Test', event.title_or_id()) def test_asText(self): # asText requires portal_transforms -- 2.30.9