[PATCH saem_ref] [eac] Display AuthorityRecord's name entries as a list with authorized forms first

Denis Laxalde denis.laxalde at logilab.fr
Tue Sep 25 13:46:54 CEST 2018


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1537869256 -7200
#      Tue Sep 25 11:54:16 2018 +0200
# Node ID 4d3586d07bd4d6489657a1cbbf24e34bbae84839
# Parent  40f49de273745dac84f6984d9fe0286437a8beb8
# Available At http://hg.logilab.org/review/cubes/saem_ref
#              hg pull http://hg.logilab.org/review/cubes/saem_ref -r 4d3586d07bd4
# EXP-Topic CONSEJIRA-580
[eac] Display AuthorityRecord's name entries as a list with authorized forms first

We use a "list" view to display the name_entry_for relation on
AuthorityRecord and sort items by putting those with "form_variant ==
'authorized'" first as requested in CONSEJIRA-580.

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
@@ -194,6 +194,15 @@ class CitationLinkView(EntityView):
             self.w(u'<i class="truncate">%s</i>' % title)
 
 
+# Use a list view to display name entries show "authorized" form first.
+pvdc.tag_object_of(('*', 'name_entry_for', 'AuthorityRecord'), {
+    'vid': 'list',
+    # we "abuse" filter option to actually sort the rset the way we want.
+    'filter': lambda rset: rset.sorted_rset(
+        lambda x: (x.form_variant != 'authorized', x.creation_date)),
+})
+
+
 class AuthorityRecordPrimaryTab(tabs.PrimaryTab):
     """Main tab for authority record, just with a different regid."""
     __regid__ = 'saem_authorityrecord_general_information_tab'



More information about the saem-devel mailing list