Skip to content

Commit b4161df

Browse files
author
Anton Prokhorov
committed
Add 'can_be_moved' method in 'PolymorphicMPTTModel'
1 parent 4e2d406 commit b4161df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

polymorphic_tree/models.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ def get_ancestors_of_type(self, model, ascending=False, include_self=False):
111111
"""
112112
return self.get_ancestors(ascending=ascending, include_self=include_self).instance_of(model)
113113

114+
def can_be_moved(self, target):
115+
"""Can move be finished
116+
117+
Method have to be redefined in inherited model to define cases when
118+
node can be moved. If method is not redefined moving always allows
119+
120+
To deny move, this method have to be raised ``ValidationError`` or
121+
``InvalidMove`` from ``mptt.exceptions``
122+
123+
Args:
124+
target (PolymorphicMPTTModel): future parent of node
125+
"""
126+
return True
127+
114128

115129
if django.VERSION < (1,7):
116130
# South integration

0 commit comments

Comments
 (0)