[PATCH 1 of 1 eac] Backport some uicfg config from saem_ref

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Feb 24 07:33:41 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487888527 -3600
#      Thu Feb 23 23:22:07 2017 +0100
# Node ID 667e280f8d36611542989aeabf2d41b38e3217cb
# Parent  2c94728b7f595aeb88cf7de76a11d9b932533f37
Backport some uicfg config from saem_ref

UI is still incomplete, but that's a start.

diff --git a/cubicweb_eac/views.py b/cubicweb_eac/views.py
--- a/cubicweb_eac/views.py
+++ b/cubicweb_eac/views.py
@@ -36,10 +36,12 @@ from cubicweb.web.views import actions, 
 from cubes.skos import to_unicode
 
 from cubicweb_eac import dataimport
 
 
+abaa = uicfg.actionbox_appearsin_addmenu
+pvs = uicfg.primaryview_section
 pvdc = uicfg.primaryview_display_ctrl
 afs = uicfg.autoform_section
 affk = uicfg.autoform_field_kwargs
 
 
@@ -48,10 +50,11 @@ affk = uicfg.autoform_field_kwargs
 actions.CopyAction.__select__ &= ~is_instance('AuthorityRecord')
 
 pvdc.tag_subject_of(('AuthorityRecord', 'agent_kind', '*'), {'vid': 'text'})
 
 for etype, attr in (
+    ('AuthorityRecord', 'record_id'),
     ('AuthorityRecord', 'isni'),
     ('AgentPlace', 'name'),
     ('AgentPlace', 'role'),
     ('Activity', 'type'),
     ('Mandate', 'term'),
@@ -65,10 +68,69 @@ for etype, attr in (
 
 
 affk.set_field_kwargs('NameEntry', 'form_variant', value=u'authorized')
 
 
+for etype, attrs in [('AgentFunction', ('name', 'description')),
+                     ('AgentPlace', ('name', 'role')),
+                     ('Mandate', ('term', 'description')),
+                     ('LegalStatus', ('term', 'description')),
+                     ('Occupation', ('term', 'description'))]:
+    affk.set_fields_order(etype, ('vocabulary_source',) + attrs)
+    if attrs[-1] == 'description':
+        affk.tag_attribute((etype, 'description'),
+                           {'help': _('let this unspecified to see the definition of the '
+                                      'related concept if a vocabulary is specifed')})
+
+afs.tag_object_of(('*', 'vocabulary_source', '*'), 'main', 'hidden')
+afs.tag_subject_of(('*', 'vocabulary_source', '*'), 'main', 'attributes')
+afs.tag_object_of(('*', 'equivalent_concept', '*'), 'main', 'hidden')
+
+pvs.tag_subject_of(('AuthorityRecord', 'postal_address', '*'), 'hidden')
+
+# Hide relation to the record for these entity types edition form.
+for etype, rtype in (
+    ('AgentPlace', 'place_agent'),
+    ('AgentFunction', 'function_agent'),
+    ('LegalStatus', 'legal_status_agent'),
+    ('Mandate', 'mandate_agent'),
+    ('History', 'history_agent'),
+    ('Structure', 'structure_agent'),
+    ('Occupation', 'occupation_agent'),
+    ('GeneralContext', 'general_context_of'),
+    ('EACSource', 'source_agent'),
+    ('EACResourceRelation', 'resource_relation_agent'),
+):
+    afs.tag_subject_of((etype, rtype, '*'), 'main', 'hidden')
+
+# Citation
+pvdc.tag_attribute(('Citation', 'uri'), {'vid': 'urlattr'})
+# Generic rules for all entity types having an `has_citation` relationship.
+afs.tag_subject_of(('*', 'has_citation', '*'), 'main', 'inlined')
+pvs.tag_object_of(('*', 'has_citation', 'Citation'), 'hidden')
+
+# AgentPlace
+afs.tag_subject_of(('AgentPlace', 'place_address', 'PostalAddress'),
+                   'main', 'inlined')
+
+# AgentFunction
+affk.set_field_kwargs('AgentFunction', 'name', widget=fw.TextInput({'size': 80}))
+
+
+afs.tag_object_of(('*', 'name_entry_for', 'AuthorityRecord'), 'main', 'inlined')
+affk.set_fields_order('AuthorityRecord', [('name_entry_for', 'object')])
+pvdc.set_fields_order('AuthorityRecord', [('name_entry_for', 'object')])
+afs.tag_object_of(('*', 'use_authorityrecord', 'AuthorityRecord'), 'main', 'hidden')
+affk.set_field_kwargs('NameEntry', 'parts', widget=fw.TextInput({'size': 80}))
+
+affk.set_field_kwargs('EACOtherRecordId', 'value', widget=fw.TextInput({'size': 80}))
+affk.set_field_kwargs('EACOtherRecordId', 'local_type', widget=fw.TextInput({'size': 80}))
+afs.tag_subject_of(('EACOtherRecordId', 'eac_other_record_id_of', '*'), 'main', 'hidden')
+
+pvdc.tag_attribute(('EACSource', 'url'), {'vid': 'urlattr'})
+
+
 def unrelated_authorityrecord(rtype, form, field, **kwargs):
     """Choices function returning AuthorityRecord choices.
 
     Choices values are unrelated through `rtype` to edited entity thus
     filtering out possible ExternalURI targets. It also account for __linkto
@@ -97,10 +159,31 @@ for etype, from_rdef, to_rdef in (
                             {'choices': partial(unrelated_authorityrecord, rtype)})
 
     pvdc.set_fields_order(etype, ('description', 'start_date',
                                   'end_date', from_rdef, to_rdef))
 
+# By default don't put anything in the 'add' submenu nor in the generic relation, expecting custom
+# views to be implemented as in the saem_ref cube
+abaa.tag_object_of(('*', 'name_entry_for', 'AuthorityRecord'), False)
+for rtype in ('eac_other_record_id_of',
+              'place_agent',
+              'function_agent',
+              'mandate_agent',
+              'occupation_agent',
+              'general_context_of',
+              'legal_status_agent',
+              'history_agent',
+              'structure_agent',
+              'source_agent',
+              'resource_relation_agent',
+              'association_from', 'association_to',
+              'chronological_predecessor', 'chronological_successor',
+              'hierarchical_parent', 'hierarchical_child'):
+    abaa.tag_object_of(('*', rtype, 'AuthorityRecord'), False)
+    afs.tag_object_of(('*', rtype, 'AuthorityRecord'), 'main', 'hidden')
+abaa.tag_subject_of(('*', 'has_citation', '*'), False)
+
 
 class XMLWrapComponent(component.EntityCtxComponent):
     """CtxComponent to display xml_wrap of entities."""
     __select__ = (
         component.EntityCtxComponent.__select__


More information about the saem-devel mailing list