return node_cls.objects.filter(parent=self)
def parent(self):
- p = self.__dict__.get('_%s_cache' % name, None)
+ if (self.parent is not None) and self.parent.node_type == name:
+ return self.parent.leaf
- if p is None and (self.parent is not None) and self.parent.node_type == name:
- p = self.parent.leaf
- self.__dict__['_%s_cache' % name] = p
-
- return p
+ return None
Node.add_to_class(name + 's', property(children))
Node.add_to_class(name, property(parent))
@classmethod
def _generate_cache_key(cls, key, group="node"):
return super(Node, cls)._generate_cache_key(key, group)
-
+
@classmethod
def get_type(cls):
return cls.__name__.lower()
return nis
+ @property
+ def last_activity(self):
+ try:
+ return self.actions.order_by('-action_date')[0].action_date
+ except:
+ return self.last_seen
+
@property
def state_list(self):
return [s.state_type for s in self.states.all()]