openslides_backend/action/actions/motion/set_state.py
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        """
        Check if the state_id is from a previous or next state.
        """
        motion = self.datastore.get(
            FullQualifiedId(Collection("motion"), instance["id"]),
            [
                "state_id",
                "meeting_id",
                "lead_motion_id",
                "category_id",
                "number",
                "number_value",
            ],
            lock_result=["state_id"],
        )
        state_id = motion["state_id"]

        motion_state = self.datastore.get(
            FullQualifiedId(Collection("motion_state"), state_id),
            ["next_state_ids", "previous_state_ids"],
        )
        is_in_next_state_ids = instance["state_id"] in motion_state.get(
            "next_state_ids", []
        )
        is_in_previous_state_ids = instance["state_id"] in motion_state.get(
            "previous_state_ids", []
        )
        if not (is_in_next_state_ids or is_in_previous_state_ids):
            raise ActionException(
                f"State '{instance['state_id']}' is not in next or previous states of the state '{state_id}'."
            )

        self.set_number(
            instance,
            motion["meeting_id"],
            instance["state_id"],
            motion.get("lead_motion_id"),
            motion.get("category_id"),
            motion.get("number"),
            motion.get("number_value"),
        )
        instance["last_modified"] = round(time.time())
        return instance

        Check if the state_id is from a previous or next state.
        
Check if the state_id is from a previous or next state.
Check if the state_id is from a previous or next state .
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        motion = self.datastore.get(
            FullQualifiedId(Collection("motion"), instance["id"]),
            [
                "state_id",
                "meeting_id",
                "lead_motion_id",
                "category_id",
                "number",
                "number_value",
            ],
            lock_result=["state_id"],
        )
        state_id = motion["state_id"]
        motion_state = self.datastore.get(
            FullQualifiedId(Collection("motion_state"), state_id),
            ["next_state_ids", "previous_state_ids"],
        )
        is_in_next_state_ids = instance["state_id"] in motion_state.get(
            "next_state_ids", []
        )
        is_in_previous_state_ids = instance["state_id"] in motion_state.get(
            "previous_state_ids", []
        )
        if not (is_in_next_state_ids or is_in_previous_state_ids):
            raise ActionException(
                f"State '{instance['state_id']}' is not in next or previous states of the state '{state_id}'."
            )
        self.set_number(
            instance,
            motion["meeting_id"],
            instance["state_id"],
            motion.get("lead_motion_id"),
            motion.get("category_id"),
            motion.get("number"),
            motion.get("number_value"),
        )
        instance["last_modified"] = round(time.time())
        return instance
def update_instance ( self , instance : Dict [ str , Any ] ) -> Dict [ str , Any ] : motion = self . datastore . get ( FullQualifiedId ( Collection ( "motion" ) , instance [ "id" ] ) , [ "state_id" , "meeting_id" , "lead_motion_id" , "category_id" , "number" , "number_value" , ] , lock_result = [ "state_id" ] , ) state_id = motion [ "state_id" ] motion_state = self . datastore . get ( FullQualifiedId ( Collection ( "motion_state" ) , state_id ) , [ "next_state_ids" , "previous_state_ids" ] , ) is_in_next_state_ids = instance [ "state_id" ] in motion_state . get ( "next_state_ids" , [ ] ) is_in_previous_state_ids = instance [ "state_id" ] in motion_state . get ( "previous_state_ids" , [ ] ) if not ( is_in_next_state_ids or is_in_previous_state_ids ) : raise ActionException ( f"State '{instance['state_id']}' is not in next or previous states of the state '{state_id}'." ) self . set_number ( instance , motion [ "meeting_id" ] , instance [ "state_id" ] , motion . get ( "lead_motion_id" ) , motion . get ( "category_id" ) , motion . get ( "number" ) , motion . get ( "number_value" ) , ) instance [ "last_modified" ] = round ( time . time ( ) ) return instance
Check if the state_id is from a previous or next state.
Check if the state_id is from a previous or next state .
"""
        Check if the state_id is from a previous or next state.
        """
self
instance
Dict[str, Any]