[PATCH 9 of 9 saem_ref] [eac] Properly skip ExternalUri in timeline

Denis Laxalde denis.laxalde at logilab.fr
Mon Mar 20 09:31:13 CET 2017


Sylvain Thenault a écrit :
> # 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 4903c283838fb8ef601ffdb57b9cdd91f36dec1c
> # Parent  35b37b8be87d1696e4917a92fd606291ed4e0d53
> [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
> @@ -686,16 +686,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})

unrelated

>          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})
>
>          _display_related(entity, 'chronological_predecessor', 'chronological_successor',
> @@ -723,15 +725,19 @@ class AuthorityRecordTimelineJsonView(En
>          data = dict(self.headers)
>          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]
> +            predecessor = successor_relation.left
> +            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]
> +            successor = predecessor_relation.right
> +            if successor.cw_etype == 'ExternalUri':
> +                continue

usage of .left/.right seems unrelated to this patch?

>              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