openslides_backend/action/actions/agenda_item/agenda_tree.py
def number_all(
        self,
        numeral_system: str = "arabic",
        agenda_number_prefix: str = None,
    ) -> Dict[int, str]:
        """
        Auto numbering of the agenda according to the numeral_system. Manually
        added item numbers will be overwritten.
        """
        new_numbers: Dict[int, str] = {}

        # Start numbering visable agenda items.
        def walk_tree(tree: Iterable[TreeElement], number: str = None) -> None:
            for index, tree_element in enumerate(tree):
                # Calculate number of visable agenda items.
                if numeral_system == "roman" and number is None:
                    item_number = to_roman(index + 1)
                else:
                    item_number = str(index + 1)
                    if number is not None:
                        item_number = ".".join((number, item_number))
                # Add prefix.
                if agenda_number_prefix:
                    item_number_tmp = f"{agenda_number_prefix} {item_number}"
                else:
                    item_number_tmp = item_number
                # Save the new value and go down the tree.
                new_numbers[tree_element.id] = item_number_tmp
                walk_tree(tree_element.children, item_number)

        walk_tree(self.get_tree(only_item_type=AgendaItem.AGENDA_ITEM))

        # Reset number of hidden items.
        for item in self.get_only_non_public_items():
            new_numbers[item["id"]] = ""

        return new_numbers

        Auto numbering of the agenda according to the numeral_system. Manually
        added item numbers will be overwritten.
        
Auto numbering of the agenda according to the numeral_system. Manually
added item numbers will be overwritten.
Auto numbering of the agenda according to the numeral_system . Manually added item numbers will be overwritten .
def number_all(
        self,
        numeral_system: str = "arabic",
        agenda_number_prefix: str = None,
    ) -> Dict[int, str]:
        new_numbers: Dict[int, str] = {}
        def walk_tree(tree: Iterable[TreeElement], number: str = None) -> None:
            for index, tree_element in enumerate(tree):
                if numeral_system == "roman" and number is None:
                    item_number = to_roman(index + 1)
                else:
                    item_number = str(index + 1)
                    if number is not None:
                        item_number = ".".join((number, item_number))
                if agenda_number_prefix:
                    item_number_tmp = f"{agenda_number_prefix} {item_number}"
                else:
                    item_number_tmp = item_number
                new_numbers[tree_element.id] = item_number_tmp
                walk_tree(tree_element.children, item_number)
        walk_tree(self.get_tree(only_item_type=AgendaItem.AGENDA_ITEM))
        for item in self.get_only_non_public_items():
            new_numbers[item["id"]] = ""
        return new_numbers
def number_all ( self , numeral_system : str = "arabic" , agenda_number_prefix : str = None , ) -> Dict [ int , str ] : new_numbers : Dict [ int , str ] = { } def walk_tree ( tree : Iterable [ TreeElement ] , number : str = None ) -> None : for index , tree_element in enumerate ( tree ) : if numeral_system == "roman" and number is None : item_number = to_roman ( index + 1 ) else : item_number = str ( index + 1 ) if number is not None : item_number = "." . join ( ( number , item_number ) ) if agenda_number_prefix : item_number_tmp = f"{agenda_number_prefix} {item_number}" else : item_number_tmp = item_number new_numbers [ tree_element . id ] = item_number_tmp walk_tree ( tree_element . children , item_number ) walk_tree ( self . get_tree ( only_item_type = AgendaItem . AGENDA_ITEM ) ) for item in self . get_only_non_public_items ( ) : new_numbers [ item [ "id" ] ] = "" return new_numbers
Auto numbering of the agenda according to the numeral_system.
Auto numbering of the agenda according to the numeral_system .
"""
        Auto numbering of the agenda according to the numeral_system. Manually
        added item numbers will be overwritten.
        """ # Start numbering visable agenda items. # Calculate number of visable agenda items. # Add prefix. # Save the new value and go down the tree. # Reset number of hidden items.
self
numeral_system
str
agenda_number_prefix
str