[PATCH 1 of 2 saem_ref] [views] Use a generic lifecycle view for skos and authority record

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 10 09:59:00 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489081267 -3600
#      Thu Mar 09 18:41:07 2017 +0100
# Node ID bbb85a687dffa6c99b6ee12b554ab624bf57d2c1
# Parent  9c7b21a9424a8272ea54203bb658b66717329da1
[views] Use a generic lifecycle view for skos and authority record

diff --git a/cubicweb_saem_ref/i18n/en.po b/cubicweb_saem_ref/i18n/en.po
--- a/cubicweb_saem_ref/i18n/en.po
+++ b/cubicweb_saem_ref/i18n/en.po
@@ -825,19 +825,19 @@ msgid "related_concept_scheme_object"
 msgstr ""
 
 msgid "removed"
 msgstr ""
 
+msgid "saem.lifecycle_tab"
+msgstr "life cycle"
+
 msgid "saem_authorityrecord_description_tab"
 msgstr "description"
 
 msgid "saem_authorityrecord_general_information_tab"
 msgstr "general information"
 
-msgid "saem_authorityrecord_lifecycle_tab"
-msgstr "life cycle"
-
 msgid "saem_authorityrecord_properties_tab"
 msgstr "properties"
 
 msgid "saem_authorityrecord_relations_tab"
 msgstr "relations"
@@ -852,13 +852,10 @@ msgid "saem_ou_authorityrecords_tab"
 msgstr "authority records"
 
 msgid "saem_ou_concepts_profiles_tab"
 msgstr "concept schemes/profiles"
 
-msgid "saem_vocabulary_lifecycle_tab"
-msgstr "life cycle"
-
 msgid "search for concepts of concept schemes"
 msgstr ""
 
 msgid "seda-actor"
 msgstr "SEDA actor"
diff --git a/cubicweb_saem_ref/i18n/fr.po b/cubicweb_saem_ref/i18n/fr.po
--- a/cubicweb_saem_ref/i18n/fr.po
+++ b/cubicweb_saem_ref/i18n/fr.po
@@ -844,19 +844,19 @@ msgid "related_concept_scheme_object"
 msgstr ""
 
 msgid "removed"
 msgstr "suppression"
 
+msgid "saem.lifecycle_tab"
+msgstr "cycle de vie"
+
 msgid "saem_authorityrecord_description_tab"
 msgstr "description"
 
 msgid "saem_authorityrecord_general_information_tab"
 msgstr "informations générales"
 
-msgid "saem_authorityrecord_lifecycle_tab"
-msgstr "cycle de vie"
-
 msgid "saem_authorityrecord_properties_tab"
 msgstr "propriétés"
 
 msgid "saem_authorityrecord_relations_tab"
 msgstr "relations"
@@ -871,13 +871,10 @@ msgid "saem_ou_authorityrecords_tab"
 msgstr "notices d'autorité"
 
 msgid "saem_ou_concepts_profiles_tab"
 msgstr "vocabulaires/profils"
 
-msgid "saem_vocabulary_lifecycle_tab"
-msgstr "cycle de vie"
-
 msgid "search for concepts of concept schemes"
 msgstr "rechercher parmi les concepts des vocabulaires contrôlés"
 
 msgid "seda-actor"
 msgstr "acteur SEDA"
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
@@ -172,11 +172,11 @@ class AuthorityRecordTabbedPrimaryView(t
     tabs = [
         _('saem_authorityrecord_general_information_tab'),
         _('saem_authorityrecord_description_tab'),
         _('saem_authorityrecord_properties_tab'),
         _('saem_authorityrecord_relations_tab'),
-        _('saem_authorityrecord_lifecycle_tab'),
+        _('saem.lifecycle_tab'),
     ]
     default_tab = 'saem_authorityrecord_general_information_tab'
 
 
 class CitationLinkView(EntityView):
@@ -269,20 +269,10 @@ class AsConceptEntityView(EntityView):
         if details:
             self._cw.add_js(('jquery.js', 'jquery.expander.js', 'cubes.saem_ref.js'))
             self.w(tags.div(details, klass='help-block truncate'))
 
 
-# AuthorityRecord life-cycle
-
-class AuthorityRecordLifeCycleTab(SubviewsTabView):
-    """Life-cycle tab for authority record."""
-    __regid__ = 'saem_authorityrecord_lifecycle_tab'
-    __select__ = EntityView.__select__ & is_instance('AuthorityRecord')
-    subvids = ('prov.activity-generated',
-               'prov.activity-associated-with')
-
-
 # AuthorityRecord EAC-CPF description tab.
 
 class AuthorityRecordDescriptionTab(SubviewsTabView):
     """Tab view gathering EAC-CPF description information of an AuthorityRecord"""
     __regid__ = 'saem_authorityrecord_description_tab'
diff --git a/cubicweb_saem_ref/views/prov.py b/cubicweb_saem_ref/views/prov.py
--- a/cubicweb_saem_ref/views/prov.py
+++ b/cubicweb_saem_ref/views/prov.py
@@ -15,14 +15,25 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-prov views/forms/actions/components for web ui"""
 
 from logilab.mtconverter import xml_escape
 
+from cubicweb.predicates import relation_possible
 from cubicweb.web.views import tableview
 
 from cubicweb_prov import views as prov
 
+from . import SubviewsTabView
+
+
+class LifeCycleTabView(SubviewsTabView):
+    """Life-cycle tab for concept and concept scheme."""
+    __regid__ = 'saem.lifecycle_tab'
+    __select__ = relation_possible('generated', role='object')
+    subvids = ('prov.activity-generated',
+               'prov.activity-associated-with')
+
 
 class ActivityGeneratedView(prov.ActivityGeneratedView):
     rql = ('Any E,T,DE,DEF,D,A,U ORDERBY D DESC '
            'WHERE E generated X, E agent A, E associated_with U?, E type T, E start D,'
            '      E description DE, E description_format DEF, X eid %(x)s')
diff --git a/cubicweb_saem_ref/views/skos.py b/cubicweb_saem_ref/views/skos.py
--- a/cubicweb_saem_ref/views/skos.py
+++ b/cubicweb_saem_ref/views/skos.py
@@ -14,15 +14,15 @@
 # You should have received a copy of the GNU Lesser General Public License along
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-saem-ref custom views for skos entities"""
 
 
-from cubicweb import NoSelectableObject, tags, _
-from cubicweb.view import EntityView, AnyRsetView
+from cubicweb import tags, _
+from cubicweb.view import AnyRsetView
 from cubicweb.predicates import is_instance
 from cubicweb.web import formwidgets as fw
-from cubicweb.web.views import baseviews, tabs, treeview, uicfg, editcontroller
+from cubicweb.web.views import baseviews, treeview, uicfg, editcontroller
 
 from cubes.skos import views as skos
 
 from . import ImportEntityComponent
 
@@ -46,26 +46,14 @@ class SKOSImportComponent(ImportEntityCo
     @property
     def import_url(self):
         return self._cw.build_url('add/skossource')
 
 
-class SKOSActivityTabView(tabs.TabsMixin, EntityView):
-    """Life-cycle tab for concept and concept scheme."""
-    __regid__ = 'saem_vocabulary_lifecycle_tab'
-    __select__ = is_instance('ConceptScheme', 'Concept')
-
-    def entity_call(self, entity):
-        try:
-            self._cw.view('prov.activity-generated', entity=entity, w=self.w, tabid=self.__regid__)
-        except NoSelectableObject:
-            self.w(u'<div>%s</div>\n' % self._cw.__('No result matching query'))
-
-
 afs.tag_object_of(('*', 'related_concept_scheme', 'ConceptScheme'), 'main', 'hidden')
 
-skos.ConceptSchemePrimaryView.tabs.append(_('saem_vocabulary_lifecycle_tab'))
-skos.ConceptPrimaryView.tabs.append(_('saem_vocabulary_lifecycle_tab'))
+skos.ConceptSchemePrimaryView.tabs.append(_('saem.lifecycle_tab'))
+skos.ConceptPrimaryView.tabs.append(_('saem.lifecycle_tab'))
 
 
 class ConceptSchemeSameETypeListView(baseviews.SameETypeListView):
     """Override SameETypeListView to display a search action on top"""
     __select__ = baseviews.SameETypeListView.__select__ & is_instance('ConceptScheme')


More information about the saem-devel mailing list