[PATCH 1 of 1 compound V2] Drop automatic clone action

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Feb 24 15:22:30 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 03180a8d84755675b112f31d47a95c792d6a1060
# 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/i18n/en.po b/i18n/en.po
--- a/i18n/en.po
+++ b/i18n/en.po
@@ -5,11 +5,8 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: pygettext.py 1.5\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-msgid "clone"
-msgstr ""
-
 #, python-format
 msgid "clone of entity #%d created"
 msgstr ""
diff --git a/i18n/fr.po b/i18n/fr.po
--- a/i18n/fr.po
+++ b/i18n/fr.po
@@ -5,11 +5,8 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: pygettext.py 1.5\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-msgid "clone"
-msgstr "cloner"
-
 #, python-format
 msgid "clone of entity #%d created"
 msgstr "un clone de l'entité #%d a été crée"
diff --git a/test/test_compound.py b/test/test_compound.py
--- a/test/test_compound.py
+++ b/test/test_compound.py
@@ -17,11 +17,10 @@
 
 from cubicweb.devtools.testlib import CubicWebTC
 
 from cubes.compound import CompositeGraph
 from cubes.compound.entities import IClonableAdapter, copy_entity
-from cubes.compound.views import CloneAction
 
 
 def sort_keys(dic):
     return dict((k, sorted(v)) for k, v in dic.items())
 
@@ -362,18 +361,10 @@ class CloneTC(CubicWebTC):
             rset = cnx.execute(
                 'Any X WHERE X name "bobby", X account AC, X biography B,'
                 '            B event E, E is Event, B event A, A narrated_by X')
             self.assertTrue(rset)
 
-    def test_clone_action(self):
-        with self.admin_access.web_request() as req:
-            entity = req.create_entity('Agent', name=u'bob')
-            req.cnx.commit()
-            action = self.vreg['actions'].select('copy', req,
-                                                 rset=entity.as_rset())
-            self.assertIsInstance(action, CloneAction)
-
     @staticmethod
     def _clone_setup(cnx):
         """Setup a graph of entities to be cloned."""
         agent = cnx.create_entity('Agent', name=u'bob')
         cnx.create_entity('OnlineAccount', reverse_account=agent)
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