openslides_backend/action/actions/speaker/create.py
def _insert_before_weight(
        self, new_id: int, weight: int, list_of_speakers_id: int
    ) -> List[int]:
        """
        We need to bild a list of speakers, sort them by weight and
        insert the new speaker before the entry with the weight from parameter
        """
        filter = And(
            FilterOperator("list_of_speakers_id", "=", list_of_speakers_id),
            FilterOperator("begin_time", "=", None),
        )
        speakers = self.datastore.filter(
            self.model.collection,
            filter=filter,
            mapped_fields=["id", "weight"],
        )
        los = sorted(speakers.values(), key=lambda k: k["weight"])
        list_to_sort = []
        for speaker in los:
            if speaker["weight"] == weight:
                list_to_sort.append(new_id)
            list_to_sort.append(speaker["id"])
        return list_to_sort

        We need to bild a list of speakers, sort them by weight and
        insert the new speaker before the entry with the weight from parameter
        
We need to bild a list of speakers, sort them by weight and
insert the new speaker before the entry with the weight from parameter
We need to bild a list of speakers sort them by weight and insert the new speaker before the entry with the weight from parameter
def _insert_before_weight(
        self, new_id: int, weight: int, list_of_speakers_id: int
    ) -> List[int]:
        filter = And(
            FilterOperator("list_of_speakers_id", "=", list_of_speakers_id),
            FilterOperator("begin_time", "=", None),
        )
        speakers = self.datastore.filter(
            self.model.collection,
            filter=filter,
            mapped_fields=["id", "weight"],
        )
        los = sorted(speakers.values(), key=lambda k: k["weight"])
        list_to_sort = []
        for speaker in los:
            if speaker["weight"] == weight:
                list_to_sort.append(new_id)
            list_to_sort.append(speaker["id"])
        return list_to_sort
def _insert_before_weight ( self , new_id : int , weight : int , list_of_speakers_id : int ) -> List [ int ] : filter = And ( FilterOperator ( "list_of_speakers_id" , "=" , list_of_speakers_id ) , FilterOperator ( "begin_time" , "=" , None ) , ) speakers = self . datastore . filter ( self . model . collection , filter = filter , mapped_fields = [ "id" , "weight" ] , ) los = sorted ( speakers . values ( ) , key = lambda k : k [ "weight" ] ) list_to_sort = [ ] for speaker in los : if speaker [ "weight" ] == weight : list_to_sort . append ( new_id ) list_to_sort . append ( speaker [ "id" ] ) return list_to_sort
We need to bild a list of speakers, sort them by weight and
insert the new speaker before the entry with the weight from parameter
We need to bild a list of speakers sort them by weight and insert the new speaker before the entry with the weight from parameter
"""
        We need to bild a list of speakers, sort them by weight and
        insert the new speaker before the entry with the weight from parameter
        """
self
new_id
int
weight
int
list_of_speakers_id
int