akvo.rsr.models.tree.model module

class akvo.rsr.models.tree.model.AkvoTreeModel(*args, **kwargs)[source]

Bases: TreeModel

class Meta[source]

Bases: object

abstract = False
ancestors(with_self=True) AkvoTreeQuerySet[source]

Get ancestors sorted by closest to farthest

That means parent, then parent’s parent, etc.

delete_parent()[source]

Basically removes all parents

descendants(max_depth: int | None = None, with_self: bool = True)[source]

All sub-nodes and their subnodes and so on

Parameters:
  • max_depth – Max amount of levels

  • with_self – Include self in the result

get_parent_uuid() UUID | None[source]
get_root() AkvoTreeModel[source]

Get the root node of a tree, which can be the node itself

property has_ancestors: bool
property manager: AkvoTreeManager
objects
parent() AkvoTreeModel | None[source]
path
set_parent(new_parent: AkvoTreeModel, force: bool = False) AkvoTreeModel[source]

Add this node as a child to a parent

There’s NO a check if this is possible. Use the helper if you want checks

uuid

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

akvo.rsr.models.tree.model.set_path(sender, **kwargs)[source]

Set path for new AkvoTreeModels

A new AkvoTreeModel doesn’t have a path set yet and it’s mandatory.