[PATCH 2 of 4 saem_ref] Follow changes in compound cube

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


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487946732 -3600
#      Fri Feb 24 15:32:12 2017 +0100
# Node ID e62af2d03c9dda1d131264dd8a963ea44d590da6
# Parent  fe349a71bc33578681b70cd558c84254180480eb
Follow changes in compound cube

the CloneAction has been dropped.

diff --git a/cubicweb_saem_ref/views/clone.py b/cubicweb_saem_ref/views/clone.py
--- a/cubicweb_saem_ref/views/clone.py
+++ b/cubicweb_saem_ref/views/clone.py
@@ -18,16 +18,16 @@
 Only used for SEDA entities for now.
 """
 
 from copy import copy
 
-from cubicweb import tags, _
-from cubicweb.predicates import has_related_entities, is_instance, is_in_state
+from cubicweb import tags, _, neg_role
+from cubicweb.predicates import (adaptable, has_permission, has_related_entities,
+                                 is_instance, is_in_state, one_line_rset)
 from cubicweb.web import component
-from cubicweb.web.views import editforms
+from cubicweb.web.views import editforms, actions
 
-from cubes.compound.views import CloneAction
 from cubicweb_seda.views.simplified import simplified_afs, simplified_pvs
 
 
 # hide default relation components for 'new_version_of' rtype
 simplified_afs.tag_subject_of(('*', 'new_version_of', '*'), 'main', 'hidden')
@@ -38,20 +38,27 @@ simplified_pvs.tag_object_of(('*', 'new_
 
 # life-cycle management ############################################################################
 
 # Only show clone action for SEDA profiles if no clone has been created yet
 
-class SEDAArchiveTransferCloneAction(CloneAction):
-    __select__ = (CloneAction.__select__
+class SEDAArchiveTransferCloneAction(actions.CopyAction):
+    __select__ = (actions.CopyAction.__select__ & one_line_rset()
+                  & adaptable('IClonable') & has_permission('add')
                   & is_instance('SEDAArchiveTransfer')
                   & ~has_related_entities('new_version_of', 'object')
                   & is_in_state('published'))
     title = _('new version')
     category = 'mainactions'
 
+    def url(self):
+        entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
+        iclone = entity.cw_adapt_to('IClonable')
+        linkto = '%s:%s:%s' % (iclone.rtype, entity.eid, neg_role(iclone.role))
+        return entity.absolute_url(vid='copy', __linkto=linkto)
 
-CloneAction.__select__ &= ~is_instance('SEDAArchiveTransfer')
+
+actions.CopyAction.__select__ &= ~adaptable('IClonable')
 
 
 class NoWarningCopyFormView(editforms.CopyFormView):
     """display primary entity creation form initialized with values from another
     entity
diff --git a/dev-requirements.txt b/dev-requirements.txt
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -2,5 +2,6 @@ pytest
 webtest
 http://hg.logilab.org/master/cubes/prov/archive/tip.tar.bz2#egg=cubicweb-prov
 http://hg.logilab.org/master/cubes/eac/archive/tip.tar.bz2#egg=cubicweb-eac
 http://hg.logilab.org/master/cubes/seda/archive/tip.tar.bz2#egg=cubicweb-seda
 http://hg.logilab.org/master/cubes/relationwidget/archive/tip.tar.bz2#egg=cubicweb-relationwidget
+http://hg.logilab.org/review/cubes/compound/archive/03180a8d8475.tar.bz2#egg=cubicweb-compound


More information about the saem-devel mailing list