[PATCH 4 of 7 saem_ref V3] [eac] Simplify timeline generation

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Mar 21 14:19:40 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490089446 -3600
#      Tue Mar 21 10:44:06 2017 +0100
# Node ID 708aa77758f125f3bc5e0782a41bc59b1310202d
# Parent  4724f37332a92482c71937f01af4fdb3e5037135
[eac] Simplify timeline generation

now that relations are also displayed as 'standard' list which offers dates,
description, we don't have to bother adding such information in timeline.

Related to #14591642

diff --git a/cubicweb_saem_ref/views/authorityrecord.py b/cubicweb_saem_ref/views/authorityrecord.py
--- a/cubicweb_saem_ref/views/authorityrecord.py
+++ b/cubicweb_saem_ref/views/authorityrecord.py
@@ -727,12 +727,11 @@ class AuthorityRecordTimelineJsonView(En
     }
 
     def entity_call(self, entity):
         data = dict(self.headers)
         data['date'] = [
-            self.entity_as_date(entity, tag=self._cw._('subject'),
-                                text=entity.dc_description()),
+            self.entity_as_date(entity, tag=self._cw._('subject')),
         ]
         for successor_relation in entity.reverse_chronological_successor:
             predecessor = successor_relation.chronological_predecessor[0]
             data['date'].append(self.entity_as_date(
                 predecessor, tag=self._cw._('chronological_predecessor')))
@@ -741,26 +740,22 @@ class AuthorityRecordTimelineJsonView(En
             data['date'].append(self.entity_as_date(
                 successor, tag=self._cw._('chronological_successor')))
         self.w(json_dumps({'timeline': data}))
 
     @staticmethod
-    def entity_as_date(entity, **kwargs):
+    def entity_as_date(entity, tag):
         """Return a dict suitable for insertion within the `date` entry of
         TimelineJS JSON structure.
         """
-        date = {}
+        date = {'tag': tag}
         calendarable = entity.cw_adapt_to('ICalendarable')
         if calendarable and (calendarable.start or calendarable.stop):
-            date.update(
-                {'headline': entity.view('incontext'),
-                 'text': entity.view('vtimeline-itemdescr')}
-            )
+            date['headline'] = entity.view('incontext')
             if calendarable.start:
                 date['startDate'] = ustrftime(calendarable.start, '%Y,%m,%d')
             if calendarable.stop:
                 date['endDate'] = ustrftime(calendarable.stop, '%Y,%m,%d')
-        date.update(kwargs)
         return date
 
 
 def _node(entity, rel=None):
     req = entity._cw


More information about the saem-devel mailing list