[PATCH 2 of 2 saem_ref] [seda] Plug activities onto archive transfer

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


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1489081332 -3600
#      Thu Mar 09 18:42:12 2017 +0100
# Node ID b12609d7988af407b34b2edb556ec579aada6afb
# Parent  bbb85a687dffa6c99b6ee12b554ab624bf57d2c1
[seda] Plug activities onto archive transfer

Related to extranet #3101354

diff --git a/cubicweb_saem_ref/entities/container.py b/cubicweb_saem_ref/entities/container.py
--- a/cubicweb_saem_ref/entities/container.py
+++ b/cubicweb_saem_ref/entities/container.py
@@ -38,21 +38,30 @@ def concept_container_def(schema):
     """Define container for Concept"""
     return structure_def(schema, 'Concept').items()
 
 
 def registration_callback(vreg):
+    # don't define IContained class for Activity, because it cause problem since it belongs to
+    # both SEDAArchiveTransfer tree and to concept/authority record tree, which don't have the
+    # same IContained implementation. Since we do not actually need this adapter on Activity,
+    # simply skip it.
+    def skip_activity(container_def_iterator):
+        for etype, parent_relations in container_def_iterator:
+            if etype != 'Activity':
+                yield etype, parent_relations
+
     vreg.register(IContainer.build_class('Organization'))
     for etype, parent_relations in org_container_def(vreg.schema):
         IContained.register_class(vreg, etype, parent_relations)
     vreg.register(IContainer.build_class('AuthorityRecord'))
-    for etype, parent_relations in authority_record_container_def(vreg.schema):
+    for etype, parent_relations in skip_activity(authority_record_container_def(vreg.schema)):
         IContained.register_class(vreg, etype, parent_relations)
     vreg.register(IContainer.build_class('ConceptScheme'))
-    for etype, parent_relations in scheme_container_def(vreg.schema):
+    for etype, parent_relations in skip_activity(scheme_container_def(vreg.schema)):
         if etype == 'Concept':
             # XXX turn parent_relations to a list to ensure broader_concept is considered first
             parent_relations = list(parent_relations)
             parent_relations.insert(0, ('broader_concept', 'subject'))
         IContained.register_class(vreg, etype, parent_relations)
     vreg.register(IContainer.build_class('Concept'))
-    for etype, parent_relations in concept_container_def(vreg.schema):
+    for etype, parent_relations in skip_activity(concept_container_def(vreg.schema)):
         IContained.register_class(vreg, etype, parent_relations)
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
@@ -519,10 +519,14 @@ msgstr "contact point of"
 
 msgctxt "Agent"
 msgid "contact_point_object"
 msgstr ""
 
+msgctxt "Activity"
+msgid "container"
+msgstr ""
+
 msgid "control"
 msgstr "control service"
 
 msgid "created"
 msgstr ""
@@ -729,16 +733,15 @@ msgstr ""
 
 msgctxt "ConceptScheme"
 msgid "generated_object"
 msgstr ""
 
-msgid "latest update on"
+msgctxt "SEDAArchiveTransfer"
+msgid "generated_object"
 msgstr ""
 
-msgid ""
-"let this unspecified to see the definition of the related concept if a "
-"vocabulary is specifed"
+msgid "latest update on"
 msgstr ""
 
 msgid "modified"
 msgstr ""
 
@@ -931,10 +934,14 @@ msgstr ""
 
 msgctxt "ConceptScheme"
 msgid "used_object"
 msgstr ""
 
+msgctxt "SEDAArchiveTransfer"
+msgid "used_object"
+msgstr ""
+
 msgid "view"
 msgstr ""
 
 msgid "view this relation"
 msgstr ""
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
@@ -533,10 +533,14 @@ msgstr "point de contact de"
 
 msgctxt "Agent"
 msgid "contact_point_object"
 msgstr ""
 
+msgctxt "Activity"
+msgid "container"
+msgstr ""
+
 msgid "control"
 msgstr "service de contrôle"
 
 msgid "created"
 msgstr "création"
@@ -746,10 +750,14 @@ msgstr ""
 
 msgctxt "ConceptScheme"
 msgid "generated_object"
 msgstr ""
 
+msgctxt "SEDAArchiveTransfer"
+msgid "generated_object"
+msgstr ""
+
 msgid "latest update on"
 msgstr "dernière mise à jour"
 
 msgid ""
 "let this unspecified to see the definition of the related concept if a "
@@ -957,10 +965,14 @@ msgstr ""
 
 msgctxt "ConceptScheme"
 msgid "used_object"
 msgstr ""
 
+msgctxt "SEDAArchiveTransfer"
+msgid "used_object"
+msgstr ""
+
 msgid "view"
 msgstr "voir"
 
 msgid "view this relation"
 msgstr "voir cette relation"
diff --git a/cubicweb_saem_ref/migration/0.15.0_Any.py b/cubicweb_saem_ref/migration/0.15.0_Any.py
new file mode 100644
--- /dev/null
+++ b/cubicweb_saem_ref/migration/0.15.0_Any.py
@@ -0,0 +1,2 @@
+add_relation_definition('Activity', 'generated', 'SEDAArchiveTransfer')
+add_relation_definition('Activity', 'used', 'SEDAArchiveTransfer')
diff --git a/cubicweb_saem_ref/schema.py b/cubicweb_saem_ref/schema.py
--- a/cubicweb_saem_ref/schema.py
+++ b/cubicweb_saem_ref/schema.py
@@ -282,16 +282,16 @@ class related_concept_scheme(RelationDef
     description = _('concept schemes used by the agent')
 
 
 class generated(RelationDefinition):
     subject = 'Activity'
-    object = ('Concept', 'ConceptScheme')
+    object = ('Concept', 'ConceptScheme', 'SEDAArchiveTransfer')
 
 
 class used(RelationDefinition):
     subject = 'Activity'
-    object = ('Concept', 'ConceptScheme')
+    object = ('Concept', 'ConceptScheme', 'SEDAArchiveTransfer')
 
 
 # ARK ##########################################################################
 
 class ark(RelationDefinition):
diff --git a/cubicweb_saem_ref/views/seda.py b/cubicweb_saem_ref/views/seda.py
--- a/cubicweb_saem_ref/views/seda.py
+++ b/cubicweb_saem_ref/views/seda.py
@@ -15,10 +15,11 @@
 # with this program. If not, see <http://www.gnu.org/licenses/>.
 """cubicweb-saem-ref views related to SEDA"""
 
 from cubicweb.web.views import uicfg
 
+from cubicweb_seda.views import archivetransfer
 from cubicweb_seda.views.simplified import simplified_afs, simplified_pvs
 
 
 # primary view configuration #######################################################################
 
@@ -44,5 +45,8 @@ simplified_pvs.tag_object_of(('*', 'use_
 simplified_afs.tag_object_of(('*', 'use_profile', '*'), 'main', 'hidden')
 
 simplified_pvs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'hidden')
 simplified_afs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'main', 'hidden')
 afs.tag_attribute(('SEDABinaryDataObject', 'filename'), 'main', 'hidden')
+
+
+archivetransfer.ArchiveTransferTabbedPrimaryView.tabs.append('saem.lifecycle_tab')
diff --git a/test/unittest_hooks.py b/test/unittest_hooks.py
--- a/test/unittest_hooks.py
+++ b/test/unittest_hooks.py
@@ -464,10 +464,20 @@ class EntityLifeCycleTC(CubicWebTC):
             rset = cnx.execute('Activity X ORDERBY X DESC WHERE X type "modify", X used %(x)s',
                                {'x': scheme.eid})
             self.assertEqual(len(rset), 2)
             self.assertEqual(rset.get_entity(0, 0).description, 'added in_scheme_object')
 
+    def test_archive_transfer_create_update(self):
+        with self.new_access(u'bob').cnx() as cnx:
+            transfer = testutils.setup_profile(cnx)
+            cnx.commit()
+            self._check_create(cnx, transfer.eid, 'created sedaarchivetransfer')
+            transfer.cw_set(title=u'123')
+            cnx.commit()
+            self._check_modification(cnx, transfer.eid,
+                                     'modified title')
+
 
 class SEDAArchiveTransferHooksTC(CubicWebTC):
 
     def test_profile_deprecated(self):
         """Test hook deprecating a SEDA Profile upon successor publication."""


More information about the saem-devel mailing list