openslides_backend/action/actions/motion_workflow/delete.py
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        """
        check if is default or last workflow of meeting.
        """
        workflow = self.datastore.fetch_model(
            FullQualifiedId(Collection("motion_workflow"), instance["id"]),
            ["meeting_id"],
        )
        if not self.is_meeting_deleted(workflow["meeting_id"]):
            meeting = self.datastore.fetch_model(
                FullQualifiedId(Collection("meeting"), workflow["meeting_id"]),
                [
                    "motions_default_workflow_id",
                    "motions_default_amendment_workflow_id",
                    "motions_default_statute_amendment_workflow_id",
                    "motion_workflow_ids",
                ],
            )
            if instance["id"] in (
                meeting.get("motions_default_workflow_id"),
                meeting.get("motions_default_amendment_workflow_id"),
                meeting.get("motions_default_statute_amendment_workflow_id"),
            ):
                raise ActionException("Cannot delete a default workflow.")

            workflow_ids = cast(List[int], meeting.get("motion_workflow_ids"))
            if len(workflow_ids) == 1:
                raise ActionException("Cannot delete the last workflow of a meeting.")

        return instance

        check if is default or last workflow of meeting.
        
check if is default or last workflow of meeting.
check if is default or last workflow of meeting .
def update_instance(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        workflow = self.datastore.fetch_model(
            FullQualifiedId(Collection("motion_workflow"), instance["id"]),
            ["meeting_id"],
        )
        if not self.is_meeting_deleted(workflow["meeting_id"]):
            meeting = self.datastore.fetch_model(
                FullQualifiedId(Collection("meeting"), workflow["meeting_id"]),
                [
                    "motions_default_workflow_id",
                    "motions_default_amendment_workflow_id",
                    "motions_default_statute_amendment_workflow_id",
                    "motion_workflow_ids",
                ],
            )
            if instance["id"] in (
                meeting.get("motions_default_workflow_id"),
                meeting.get("motions_default_amendment_workflow_id"),
                meeting.get("motions_default_statute_amendment_workflow_id"),
            ):
                raise ActionException("Cannot delete a default workflow.")
            workflow_ids = cast(List[int], meeting.get("motion_workflow_ids"))
            if len(workflow_ids) == 1:
                raise ActionException("Cannot delete the last workflow of a meeting.")
        return instance
def update_instance ( self , instance : Dict [ str , Any ] ) -> Dict [ str , Any ] : workflow = self . datastore . fetch_model ( FullQualifiedId ( Collection ( "motion_workflow" ) , instance [ "id" ] ) , [ "meeting_id" ] , ) if not self . is_meeting_deleted ( workflow [ "meeting_id" ] ) : meeting = self . datastore . fetch_model ( FullQualifiedId ( Collection ( "meeting" ) , workflow [ "meeting_id" ] ) , [ "motions_default_workflow_id" , "motions_default_amendment_workflow_id" , "motions_default_statute_amendment_workflow_id" , "motion_workflow_ids" , ] , ) if instance [ "id" ] in ( meeting . get ( "motions_default_workflow_id" ) , meeting . get ( "motions_default_amendment_workflow_id" ) , meeting . get ( "motions_default_statute_amendment_workflow_id" ) , ) : raise ActionException ( "Cannot delete a default workflow." ) workflow_ids = cast ( List [ int ] , meeting . get ( "motion_workflow_ids" ) ) if len ( workflow_ids ) == 1 : raise ActionException ( "Cannot delete the last workflow of a meeting." ) return instance
check if is default or last workflow of meeting.
check if is default or last workflow of meeting .
"""
        check if is default or last workflow of meeting.
        """
self
instance
Dict[str, Any]