[PATCH 7 of 7 saem_ref V2] [eac] Properly skip ExternalUri in timeline

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Mar 21 10:50:11 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489675201 -3600
#      Thu Mar 16 15:40:01 2017 +0100
# Node ID 14cbf2d752e9d67df266d691e8ece965fe13c2bb
# Parent  89c7564dcf3a3ae1520588fcd4a82b40a59ea5ef
[eac] Properly skip ExternalUri in timeline

else it ends up crashing.

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
@@ -689,16 +689,18 @@ class ChronologicalRelationView(EntityVi
         has_related_entities('chronological_predecessor', role='object'))
     title = _('ChronologicalRelation_plural')
 
     def entity_call(self, entity, **kwargs):
         self.w(tags.h2(self._cw._(self.title).lower()))
-        rset = self._cw.execute('(Any X WHERE X eid %(eid)s) '
-                                'UNION (Any S WHERE RP chronological_predecessor X, '
-                                '       RP chronological_successor S, X eid %(eid)s) '
-                                'UNION (Any P WHERE RS chronological_successor X, '
-                                '       RS chronological_predecessor P, X eid %(eid)s)',
-                                {'eid': entity.eid})
+
+        rset = self._cw.execute(
+            '(Any X WHERE X eid %(eid)s) '
+            'UNION (Any S WHERE S is AuthorityRecord, RP chronological_predecessor X, '
+            '       RP chronological_successor S, X eid %(eid)s) '
+            'UNION (Any P WHERE P is AuthorityRecord, RS chronological_successor X, '
+            '       RS chronological_predecessor P, X eid %(eid)s)',
+            {'eid': entity.eid})
         json_url = self._cw.build_url('view', rql=entity.as_rset().printable_rql(),
                                       vid='saem.authorityrecord-timeline-json')
         self._cw.view('vtimeline', rset=rset, w=self.w, custom_settings={'source': json_url})
 
         self._cw.view('saem.authorityrecord.relation.related', entity=entity, w=self.w,
@@ -731,14 +733,18 @@ class AuthorityRecordTimelineJsonView(En
         data['date'] = [
             self.entity_as_date(entity, tag=self._cw._('subject')),
         ]
         for successor_relation in entity.reverse_chronological_successor:
             predecessor = successor_relation.chronological_predecessor[0]
+            if predecessor.cw_etype == 'ExternalUri':
+                continue
             data['date'].append(self.entity_as_date(
                 predecessor, tag=self._cw._('chronological_predecessor')))
         for predecessor_relation in entity.reverse_chronological_predecessor:
             successor = predecessor_relation.chronological_successor[0]
+            if successor.cw_etype == 'ExternalUri':
+                continue
             data['date'].append(self.entity_as_date(
                 successor, tag=self._cw._('chronological_successor')))
         self.w(json_dumps({'timeline': data}))
 
     @staticmethod


More information about the saem-devel mailing list