[PATCH 4 of 4 saem_ref] Follow changes in the eac cube

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Feb 24 16:06:39 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487948263 -3600
#      Fri Feb 24 15:57:43 2017 +0100
# Node ID 8eede67d489f5cf4ac333d67279dc23aa14a1654
# Parent  3432a5b5af90222d5a25bcc1a000a4c788a1ae98
Follow changes in the eac cube

Some uicfg rules have been backported there.

diff --git a/cubicweb_saem_ref/entities/eac.py b/cubicweb_saem_ref/entities/eac.py
--- a/cubicweb_saem_ref/entities/eac.py
+++ b/cubicweb_saem_ref/entities/eac.py
@@ -32,10 +32,13 @@ ARECORD_METADATA_FORMATS = {
         'eac.export',
     ),
 }
 
 
+eac.AuthorityRecord.fetch_attrs.append('ark')
+
+
 class AuthorityRecordEACAdapter(eac.AuthorityRecordEACAdapter):
 
     @property
     def file_name(self):
         """Return a file name for the dump."""
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
@@ -34,11 +34,10 @@ from .. import cwuri_url, user_has_autho
 from . import (ImportEntityComponent, RelatedEntitiesListView, SubviewsTabView,
                RelationInfo, editlinks, external_link)
 from .widgets import JQueryIncompleteDatePicker, ConceptAutoCompleteWidget
 
 
-abaa = uicfg.actionbox_appearsin_addmenu
 pvs = uicfg.primaryview_section
 pvdc = uicfg.primaryview_display_ctrl
 afs = uicfg.autoform_section
 aff = uicfg.autoform_field
 affk = uicfg.autoform_field_kwargs
@@ -115,19 +114,11 @@ for etype, attrs in [('AgentFunction', (
                      ('AgentPlace', ('name', 'role')),
                      ('Mandate', ('term', 'description')),
                      ('LegalStatus', ('term', 'description')),
                      ('Occupation', ('term', 'description'))]:
     aff.tag_subject_of((etype, attrs[0], '*'), EquivalentConceptOrTextField)
-    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')
 # handled by EquivalentConceptOrTextField
 afs.tag_subject_of(('*', 'equivalent_concept', '*'), 'main', 'hidden')
 pvs.tag_subject_of(('*', 'equivalent_concept', '*'), 'attributes')
 pvs.tag_object_of(('*', 'vocabulary_source', '*'), 'hidden')
 
@@ -168,28 +159,10 @@ affk.set_field_kwargs('NameEntry', 'form
 pvs.tag_attribute(('AuthorityRecord', 'record_id'), 'hidden')
 afs.tag_attribute(('AuthorityRecord', 'record_id'), 'main', 'hidden')
 
 afs.tag_object_of(('*', 'authority_record', 'AuthorityRecord'), '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')
-
-
 # AuthorityRecord primary views (tabs)
 
 class AuthorityRecordTabbedPrimaryView(tabs.TabbedPrimaryView):
     """Tabbed primary view for AuthorityRecord"""
     __select__ = tabs.TabbedPrimaryView.__select__ & is_instance('AuthorityRecord')
@@ -201,18 +174,10 @@ class AuthorityRecordTabbedPrimaryView(t
         _('saem_authorityrecord_lifecycle_tab'),
     ]
     default_tab = 'saem_authorityrecord_general_information_tab'
 
 
-# Citation
-pvdc.tag_attribute(('Citation', 'uri'), {'vid': 'urlattr'})
-# Generic rules for all entity types having an `has_citation` relationship.
-abaa.tag_subject_of(('*', 'has_citation', '*'), False)
-afs.tag_subject_of(('*', 'has_citation', '*'), 'main', 'inlined')
-pvs.tag_object_of(('*', 'has_citation', 'Citation'), 'hidden')
-
-
 class CitationLinkView(EntityView):
     __regid__ = 'citation-link'
     __select__ = is_instance('Citation')
 
     def entity_call(self, entity):
@@ -226,18 +191,10 @@ class CitationLinkView(EntityView):
             title = (entity.note or
                      u'{0} #{1}'.format(self._cw._('Citation'), entity.eid))
             self.w(u'<i class="truncate">%s</i>' % title)
 
 
-# In the main tab.
-
-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')
-
-
 class AuthorityRecordPrimaryTab(tabs.PrimaryTab):
     """Main tab for authority record, just with a different regid."""
     __regid__ = 'saem_authorityrecord_general_information_tab'
 
 
@@ -349,18 +306,10 @@ class AuthorityRecordDescriptionTab(Subv
         ('history_agent', 'object'),
         ('structure_agent', 'object'),
     ]
 
 
-pvs.tag_object_of(('*', 'eac_other_record_id_of', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'eac_other_record_id_of', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'eac_other_record_id_of', 'AuthorityRecord'), False)
-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')
-
-
 class AuthorityRecordOtherRecordIdView(RelatedEntitiesListView):
     """View for EACOtherRecordId, to be display in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.other_record_id'
     rtype = 'eac_other_record_id_of'
     subvid = 'saem_ref.authorityrecord.other_record_id.listitem'
@@ -381,12 +330,10 @@ class OtherRecordIdListItemView(EntityVi
             self.wdata(u' ({0})'.format(entity.local_type))
         self.w(u'</div>')
 
 
 pvs.tag_object_of(('*', 'place_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'place_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'place_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordPlaceView(RelatedEntitiesListView):
     """View for AuthorityRecordPlace, to be display in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.places'
@@ -419,12 +366,10 @@ class AuthorityRecordPlaceAsConceptView(
         if address:
             self._cw.view('incontext', rset=address.as_rset(), w=self.w)
 
 
 pvs.tag_object_of(('*', 'function_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'function_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'function_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordFunctionView(RelatedEntitiesListView):
     """View for AgentFunction, to be display in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.functions'
@@ -434,12 +379,10 @@ class AuthorityRecordFunctionView(Relate
                      'details_attr': 'description'}
     _('creating AgentFunction (AgentFunction function_agent AuthorityRecord %(linkto)s)')
 
 
 pvs.tag_object_of(('*', 'mandate_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'mandate_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'mandate_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordMandateView(RelatedEntitiesListView):
     """View for Mandate, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.mandate'
@@ -450,12 +393,10 @@ class AuthorityRecordMandateView(Related
                      'details_attr': 'description'}
     _('creating Mandate (Mandate mandate_agent AuthorityRecord %(linkto)s)')
 
 
 pvs.tag_object_of(('*', 'occupation_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'occupation_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'occupation_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordOccupationView(RelatedEntitiesListView):
     """View for Occupation, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.occupation'
@@ -466,12 +407,10 @@ class AuthorityRecordOccupationView(Rela
                      'details_attr': 'description'}
     _('creating Occupation (Occupation occupation_agent AuthorityRecord %(linkto)s)')
 
 
 pvs.tag_object_of(('*', 'general_context_of', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'general_context_of', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'general_context_of', 'AuthorityRecord'), False)
 
 
 class GeneralContextView(RelatedEntitiesListView):
     """View for GeneralContext, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.generalcontext'
@@ -504,12 +443,10 @@ class WithCitationTextAttributeView(With
     """Extend text_attribute view when entity has related citations."""
     __select__ = TextAttributeView.__select__ & WithCitationViewMixIn.__select__
 
 
 pvs.tag_object_of(('*', 'legal_status_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'legal_status_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'legal_status_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordLegalStatusView(RelatedEntitiesListView):
     """View for LegalStatus, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.legal_status'
@@ -519,12 +456,10 @@ class AuthorityRecordLegalStatusView(Rel
                      'details_attr': 'description'}
     _('creating LegalStatus (LegalStatus legal_status_agent AuthorityRecord %(linkto)s)')
 
 
 pvs.tag_object_of(('*', 'history_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'history_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'history_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordHistoryView(RelatedEntitiesListView):
     """View for History, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.history'
@@ -533,12 +468,10 @@ class AuthorityRecordHistoryView(Related
     subvid_kwargs = {'text_attr': 'text'}
     _('creating History (History history_agent AuthorityRecord %(linkto)s)')
 
 
 pvs.tag_object_of(('*', 'structure_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'structure_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'structure_agent', 'AuthorityRecord'), False)
 
 
 class AuthorityRecordStructureView(RelatedEntitiesListView):
     """View for Structure, to be displayed in the context of an AuthorityRecord"""
     __regid__ = 'saem_ref.authorityrecord.structure'
@@ -574,12 +507,10 @@ class AuthorityRecordPropertiesTab(Subvi
         ('resource_relation_agent', 'object'),
     ]
 
 
 pvs.tag_object_of(('*', 'source_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'source_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'source_agent', 'AuthorityRecord'), False)
 
 pvdc.tag_attribute(('EACSource', 'url'), {'vid': 'urlattr'})
 
 
 class AuthorityRecordEACSourceView(RelatedEntitiesListView):
@@ -606,12 +537,10 @@ class EACSourceListItemView(EntityView):
         if entity.url:
             entity.view('saem.external_link', rtype='url', w=self.w)
 
 
 pvs.tag_object_of(('*', 'resource_relation_agent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'resource_relation_agent', 'AuthorityRecord'), 'main', 'hidden')
-abaa.tag_object_of(('*', 'resource_relation_agent', 'AuthorityRecord'), False)
 
 pvdc.tag_subject_of(('EACResourceRelation', 'resource_relation_resource', '*'),
                     {'vid': 'saem.external_link'})
 
 
@@ -672,13 +601,11 @@ class AuthorityRecordRelationsTab(Subvie
         ('association_from', 'object'),
     ]
 
 
 pvs.tag_object_of(('*', 'association_from', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'association_from', 'AuthorityRecord'), 'main', 'hidden')
 pvs.tag_object_of(('*', 'association_to', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'association_to', 'AuthorityRecord'), 'main', 'hidden')
 
 
 class AuthorityRecordAssociationRelationView(EntityView):
     """View for association relations to be displayed in the context of an
     AuthorityRecord on either the `from` or `to` side of the relation.
@@ -724,13 +651,11 @@ class AssociationRelationView(EntityView
         if entity.description:
             self.w(tags.div(entity.printable_value('description')))
 
 
 pvs.tag_object_of(('*', 'chronological_predecessor', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'chronological_predecessor', 'AuthorityRecord'), 'main', 'hidden')
 pvs.tag_object_of(('*', 'chronological_successor', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'chronological_successor', 'AuthorityRecord'), 'main', 'hidden')
 
 
 class ChronologicalRelationView(EntityView):
     """Timeline view with authority records involved in a ChronologicalRelation with this authority
     record entity.
@@ -919,16 +844,6 @@ class AuthorityRecordGraphView(EntityVie
             self._cw.view('list', rset_parents, w=self.w)
             self.w(u'</div>')
 
 
 pvs.tag_object_of(('*', 'hierarchical_parent', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'hierarchical_parent', 'AuthorityRecord'), 'main', 'hidden')
-
 pvs.tag_object_of(('*', 'hierarchical_child', 'AuthorityRecord'), 'hidden')
-afs.tag_object_of(('*', 'hierarchical_child', 'AuthorityRecord'), 'main', 'hidden')
-
-# AgentPlace
-afs.tag_subject_of(('AgentPlace', 'place_address', 'PostalAddress'),
-                   'main', 'inlined')
-
-# AgentFunction
-affk.set_field_kwargs('AgentFunction', 'name', widget=fw.TextInput({'size': 80}))


More information about the saem-devel mailing list