[ui] Factorize list of entity types for typed references
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 12 Jul 2016 15:55:25 +0200
changeset 1418 ca2fe27ff204
parent 1417 50e9afea655e
child 1419 010bc985bc6e
[ui] Factorize list of entity types for typed references
views/content.py
--- a/views/content.py	Tue Jul 12 15:20:47 2016 +0200
+++ b/views/content.py	Tue Jul 12 15:55:25 2016 +0200
@@ -341,10 +341,15 @@
             self.w(u'<br/><span>{0} {1}</span>'.format(msg, kwr.view('seda.xsdmeta')))
 
 
+TYPED_REFERENCE_ENTITY_TYPES = ('SEDAAltIsPartOfArchiveUnitRefId',
+                                'SEDAAltIsVersionOfArchiveUnitRefId',
+                                'SEDAAltReferencesArchiveUnitRefId',
+                                'SEDAAltReplacesArchiveUnitRefId',
+                                'SEDAAltRequiresArchiveUnitRefId')
+
+
 class BusinessValueLinkedEntityView(viewlib.BusinessValueEntityView):
-    __select__ = is_instance('SEDAIsVersionOf', 'SEDAIsPartOf',
-                             'SEDAReplaces', 'SEDARequires',
-                             'SEDAReferences')
+    __select__ = is_instance(*TYPED_REFERENCE_ENTITY_TYPES)
 
     def entity_value(self, entity):
         alt_rtype = (un_camel_case(entity.cw_etype).replace('seda_', 'seda_alt_')
@@ -373,11 +378,7 @@
 dor_afs.__select__ = is_instance('SEDADataObjectReference') & is_typed_reference()
 dor_afs.tag_attribute(('SEDADataObjectReference', 'user_cardinality'), 'main', 'hidden')
 
-for etype in ('SEDAAltIsPartOfArchiveUnitRefId',
-              'SEDAAltIsVersionOfArchiveUnitRefId',
-              'SEDAAltReferencesArchiveUnitRefId',
-              'SEDAAltReplacesArchiveUnitRefId',
-              'SEDAAltRequiresArchiveUnitRefId'):
+for etype in TYPED_REFERENCE_ENTITY_TYPES:
     affk.set_fields_order(etype, [('seda_data_object_reference', 'object'),
                                   ('seda_repository_object_pid', 'object'),
                                   ('seda_archive_unit_ref_id_from', 'object'),