openslides_backend/action/actions/agenda_item/create.py
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        """
        If parent_id is given, set weight to parent.weight + 1
        """
        instance = super().update_instance(instance)
        if instance.get("parent_id") is None:
            return instance
        parent = self.datastore.fetch_model(
            FullQualifiedId(Collection("agenda_item"), instance["parent_id"]),
            ["child_ids"],
        )
        max_weight = 0
        for child_id in parent.get("child_ids", []):
            child = self.datastore.fetch_model(
                FullQualifiedId(Collection("agenda_item"), child_id),
                ["weight"],
            )
            if child.get("weight", 0) > max_weight:
                max_weight = child["weight"]
        instance["weight"] = max_weight + 1
        return instance

        If parent_id is given, set weight to parent.weight + 1
        
If parent_id is given, set weight to parent.weight + 1
If parent_id is given set weight to parent . weight + 1
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        instance = super().update_instance(instance)
        if instance.get("parent_id") is None:
            return instance
        parent = self.datastore.fetch_model(
            FullQualifiedId(Collection("agenda_item"), instance["parent_id"]),
            ["child_ids"],
        )
        max_weight = 0
        for child_id in parent.get("child_ids", []):
            child = self.datastore.fetch_model(
                FullQualifiedId(Collection("agenda_item"), child_id),
                ["weight"],
            )
            if child.get("weight", 0) > max_weight:
                max_weight = child["weight"]
        instance["weight"] = max_weight + 1
        return instance
def update_instance ( self , instance : Dict [ str , Any ] ) -> Dict [ str , Any ] : instance = super ( ) . update_instance ( instance ) if instance . get ( "parent_id" ) is None : return instance parent = self . datastore . fetch_model ( FullQualifiedId ( Collection ( "agenda_item" ) , instance [ "parent_id" ] ) , [ "child_ids" ] , ) max_weight = 0 for child_id in parent . get ( "child_ids" , [ ] ) : child = self . datastore . fetch_model ( FullQualifiedId ( Collection ( "agenda_item" ) , child_id ) , [ "weight" ] , ) if child . get ( "weight" , 0 ) > max_weight : max_weight = child [ "weight" ] instance [ "weight" ] = max_weight + 1 return instance
If parent_id is given, set weight to parent.weight + 1
If parent_id is given set weight to parent . weight + 1
"""
        If parent_id is given, set weight to parent.weight + 1
        """
self
instance
Dict[str, Any]