Commit de93e952 authored by Jérome Perrin's avatar Jérome Perrin

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
parent 18293f33
...@@ -215,7 +215,7 @@ class EmailDocument(File, TextDocument): ...@@ -215,7 +215,7 @@ class EmailDocument(File, TextDocument):
security.declareProtected(Permissions.AccessContentsInformation, 'getTitle') security.declareProtected(Permissions.AccessContentsInformation, 'getTitle')
def getTitle(self, default=_MARKER): def getTitle(self, default=_MARKER):
""" """
Returns the title Returns the title from the mail subject
""" """
if not self.hasFile(): if not self.hasFile():
# Return the standard text content if no file was provided # Return the standard text content if no file was provided
...@@ -225,10 +225,15 @@ class EmailDocument(File, TextDocument): ...@@ -225,10 +225,15 @@ class EmailDocument(File, TextDocument):
return self._baseGetTitle(default) return self._baseGetTitle(default)
return self.getContentInformation().get('Subject', '') 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') security.declareProtected(Permissions.AccessContentsInformation, 'getStartDate')
def getStartDate(self, default=_MARKER): def getStartDate(self, default=_MARKER):
""" """
Returns the title Returns the date from the mail date
""" """
if not self.hasFile(): if not self.hasFile():
# Return the standard start date if no file was provided # Return the standard start date if no file was provided
......
...@@ -370,6 +370,8 @@ class TestCRMMailIngestion(ERP5TypeTestCase): ...@@ -370,6 +370,8 @@ class TestCRMMailIngestion(ERP5TypeTestCase):
# tite is found automatically, based on the Subject: header in the mail # tite is found automatically, based on the Subject: header in the mail
event = self._ingestMail('simple') event = self._ingestMail('simple')
self.assertEquals('Simple Mail Test', event.getTitle()) 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): def test_asText(self):
# asText requires portal_transforms # asText requires portal_transforms
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment