Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compound
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
compound
Commits
b4c29f63b187
Commit
b4c29f63b187
authored
8 years ago
by
Sylvain Thénault
Browse files
Options
Downloads
Patches
Plain Diff
Make CloneAction abstract
we don't want it to appear auto-magically for every IClonable entities
parent
3a080ed72f55
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/data/entities.py
+6
-1
6 additions, 1 deletion
test/data/entities.py
views.py
+12
-3
12 additions, 3 deletions
views.py
with
18 additions
and
4 deletions
test/data/entities.py
+
6
−
1
View file @
b4c29f63
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
'
))
...
...
This diff is collapsed.
Click to expand it.
views.py
+
12
−
3
View file @
b4c29f63
...
...
@@ -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
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment