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

Make CloneAction abstract

we don't want it to appear auto-magically for every IClonable entities
parent 3a080ed72f55
No related branches found
No related tags found
No related merge requests found
from cubicweb.predicates import has_related_entities
from cubicweb.predicates import has_related_entities, is_instance
from cubes.compound.entities import (IClonableAdapter, IContained, IContainer,
structure_def)
......@@ -2,6 +2,7 @@
from cubes.compound.entities import (IClonableAdapter, IContained, IContainer,
structure_def)
from cubes.compound.views import CloneAction
def agent_structure_def(schema):
......@@ -22,6 +23,10 @@
follow_relations = [('member', 'object')]
class AgentCloneAction(CloneAction):
__select__ = CloneAction.__select__ & is_instance('Agent')
def registration_callback(vreg):
vreg.register_all(globals().values(), __name__)
vreg.register(IContainer.build_class('Agent'))
......
......@@ -26,9 +26,16 @@
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'))
"""Abstract clone action of ICloneable entities.
Simply inherit from it with a specific selector if you want to activate it.
The action will link to the copy form with shallow copy message disabled and
linkto information to rely on the clone hook for the actual cloning.
"""
__abstract__ = True
__select__ = (actions.CopyAction.__select__ & one_line_rset()
& has_permission('add')
& adaptable('IClonable'))
title = _('clone')
def url(self):
......@@ -38,6 +45,8 @@
return entity.absolute_url(vid='copy', __linkto=linkto)
# In any case IClonable entities want default copy disabled since it wont handle
# composite relations by default.
actions.CopyAction.__select__ &= ~adaptable('IClonable')
......
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