[entities] BlogEntry.dc_date() should return publication date when published (closes #2157366) stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 01 Mar 2012 16:11:47 +0100
branchstable
changeset 274 5ad30b94a083
parent 273 1e3f1122e4aa
child 275 ef07b3e39a1f
[entities] BlogEntry.dc_date() should return publication date when published (closes #2157366)
entities.py
--- a/entities.py	Fri Feb 03 17:41:41 2012 +0100
+++ b/entities.py	Thu Mar 01 16:11:47 2012 +0100
@@ -48,10 +48,13 @@
     def dc_description(self, format='text/plain'):
         return self.printable_value('content', format=format)
 
-    def dc_date(self, date_format=None):# XXX default to ISO 8601 ?
-        """return latest modification date of this entity"""
-        return self._cw.format_date(self.creation_date, date_format=date_format)
-
+    def dc_date(self, date_format=None):
+        dc_date = self.creation_date
+        for tr_info in self.reverse_wf_info_for:
+            if tr_info.new_state.name == 'published':
+                dc_date = tr_info.creation_date
+                break
+        return self._cw.format_date(dc_date, date_format=date_format)
 
 class BlogEntryICalendarableAdapter(EntityAdapter):
     __regid__ = 'ICalendarable'