[PATCH compound] Drop automatic clone action

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Feb 24 14:56:35 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487944497 -3600
#      Fri Feb 24 14:54:57 2017 +0100
# Node ID 0ec135c08c357e3ae746d2bb5cf25d2a63529978
# Parent  624ecd0a4f64b080d00613e94f05ae1b6f8df424
Drop automatic clone action

Being adaptable to IClonable doesn't mean we want a clone action in the UI,
furthermore when it leads by default to the clumsy 'copy' form.

diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -13,36 +13,18 @@
 #
 # 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-compound views/forms/actions/components for web ui"""
 
-from cubicweb import _, neg_role
 from cubicweb.web import Redirect
-from cubicweb.predicates import (one_line_rset, adaptable, has_permission,
-                                 match_form_params)
+from cubicweb.predicates import adaptable, match_form_params
 from cubicweb.web.controller import Controller
-from cubicweb.web.views import actions, ibreadcrumbs
+from cubicweb.web.views import ibreadcrumbs
 
 from cubes.compound.entities import copy_entity
 
 
-class CloneAction(actions.CopyAction):
-    """Just a copy action (copy is handled by edit controller below) named 'clone'."""
-    __select__ = (actions.CopyAction.__select__ & one_line_rset() &
-                  adaptable('IClonable') & has_permission('add'))
-    title = _('clone')
-
-    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)
-
-
-actions.CopyAction.__select__ &= ~adaptable('IClonable')
-
-
 class CloneController(Controller):
     """Controller handling cloning of the original entity (with `eid` passed
     in form parameters). Redirects to the cloned entity primary view.
     """
     __regid__ = 'compound.clone'


More information about the saem-devel mailing list