git.ithinksw.org
/
philo.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' of git://github.com/lapilofu/philo into develop
[philo.git]
/
philo
/
models
/
base.py
diff --git
a/philo/models/base.py
b/philo/models/base.py
index
d1dc38a
..
8df67c3
100644
(file)
--- a/
philo/models/base.py
+++ b/
philo/models/base.py
@@
-471,14
+471,15
@@
class TreeEntity(Entity, MPTTModel):
if root == self:
return ''
if root == self:
return ''
- if root is None and self.is_root_node():
+ parent_id = getattr(self, "%s_id" % self._mptt_meta.parent_attr)
+ if getattr(root, 'pk', None) == parent_id:
return getattr(self, field, '?')
if root is not None and not self.is_descendant_of(root):
raise AncestorDoesNotExist(root)
if memoize:
return getattr(self, field, '?')
if root is not None and not self.is_descendant_of(root):
raise AncestorDoesNotExist(root)
if memoize:
- memo_args = (
getattr(self, "%s_id" % self._mptt_meta.parent_attr)
, getattr(root, 'pk', None), pathsep, getattr(self, field, '?'))
+ memo_args = (
parent_id
, getattr(root, 'pk', None), pathsep, getattr(self, field, '?'))
try:
return self._path_memo[memo_args]
except AttributeError:
try:
return self._path_memo[memo_args]
except AttributeError:
@@
-515,7
+516,7
@@
class TreeEntity(Entity, MPTTModel):
"""
if mapper is None:
"""
if mapper is None:
- if
self.parent
:
+ if
getattr(self, "%s_id" % self._mptt_meta.parent_attr)
:
mapper = TreeAttributeMapper
else:
mapper = AttributeMapper
mapper = TreeAttributeMapper
else:
mapper = AttributeMapper
@@
-542,7
+543,7
@@
class SlugTreeEntity(TreeEntity):
path = property(get_path)
def clean(self):
path = property(get_path)
def clean(self):
- if
self.parent
is None:
+ if
getattr(self, "%s_id" % self._mptt_meta.parent_attr)
is None:
try:
self._default_manager.exclude(pk=self.pk).get(slug=self.slug, parent__isnull=True)
except self.DoesNotExist:
try:
self._default_manager.exclude(pk=self.pk).get(slug=self.slug, parent__isnull=True)
except self.DoesNotExist: