Skip to content
Snippets Groups Projects
Commit 09d13e5869ac authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Extract part of CloneAction.url into a linkto_clone_url_params function

and test it.
parent b4c29f63b187
No related branches found
No related tags found
No related merge requests found
...@@ -371,6 +371,7 @@ ...@@ -371,6 +371,7 @@
action = self.vreg['actions'].select('copy', req, action = self.vreg['actions'].select('copy', req,
rset=entity.as_rset()) rset=entity.as_rset())
self.assertIsInstance(action, CloneAction) self.assertIsInstance(action, CloneAction)
self.assertIn('clone_of', action.url())
@staticmethod @staticmethod
def _clone_setup(cnx): def _clone_setup(cnx):
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
from cubes.compound.entities import copy_entity from cubes.compound.entities import copy_entity
def linkto_clone_url_params(entity):
iclone = entity.cw_adapt_to('IClonable')
linkto = '%s:%s:%s' % (iclone.rtype, entity.eid, neg_role(iclone.role))
return {'__linkto': linkto}
class CloneAction(actions.CopyAction): class CloneAction(actions.CopyAction):
"""Abstract clone action of ICloneable entities. """Abstract clone action of ICloneable entities.
...@@ -40,9 +46,7 @@ ...@@ -40,9 +46,7 @@
def url(self): def url(self):
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0)
iclone = entity.cw_adapt_to('IClonable') return entity.absolute_url(vid='copy', **linkto_clone_url_params(entity))
linkto = '%s:%s:%s' % (iclone.rtype, entity.eid, neg_role(iclone.role))
return entity.absolute_url(vid='copy', __linkto=linkto)
# In any case IClonable entities want default copy disabled since it wont handle # In any case IClonable entities want default copy disabled since it wont handle
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment