openslides_backend/action/actions/speaker/create.py
def validate_fields(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        """
        Checks
        - that only the requesting user can file a point-of-order
        - that a new speaker does not already exist on the list of speaker as
        waiting speaker (with begin_time == None), but allows one additional with point_of_order speaker per user
        - that points_of_order are used in this meeting
        - that user has to be present to be added to the list of speakers
        - that request-user cannot create a speaker without being point_of_order, a not closed los is closed and no list_of_speakers.can_manage permission
        """
        if instance.get("point_of_order") and instance.get("user_id") != self.user_id:
            raise ActionException(
                f"The requesting user {self.user_id} is not the user {instance.get('user_id')} the point-of-order is filed for."
            )
        los_fqid = FullQualifiedId(
            Collection("list_of_speakers"), instance["list_of_speakers_id"]
        )
        los = self.datastore.get(los_fqid, ["meeting_id", "closed"])
        meeting_id = los["meeting_id"]
        meeting_fqid = FullQualifiedId(Collection("meeting"), meeting_id)
        meeting = self.datastore.get(
            meeting_fqid,
            [
                "list_of_speakers_enable_point_of_order_speakers",
                "list_of_speakers_present_users_only",
            ],
        )
        if instance.get("point_of_order") and not meeting.get(
            "list_of_speakers_enable_point_of_order_speakers"
        ):
            raise ActionException(
                "Point of order speakers are not enabled for this meeting."
            )

        if (
            not instance.get("point_of_order")
            and los.get("closed")
            and instance.get("user_id") == self.user_id
            and not has_perm(
                self.datastore,
                self.user_id,
                Permissions.ListOfSpeakers.CAN_MANAGE,
                meeting_id,
            )
        ):
            raise ActionException("The list of speakers is closed.")
        if meeting.get("list_of_speakers_present_users_only"):
            user_fqid = FullQualifiedId(Collection("user"), instance["user_id"])
            user = self.datastore.get(user_fqid, ["is_present_in_meeting_ids"])
            if meeting_id not in user.get("is_present_in_meeting_ids", ()):
                raise ActionException(
                    "Only present users can be on the lists of speakers."
                )

        # Results are necessary, because of getting a lock_result
        filter_obj = And(
            FilterOperator("list_of_speakers_id", "=", instance["list_of_speakers_id"]),
            FilterOperator("begin_time", "=", None),
        )
        speakers = self.datastore.filter(
            collection=Collection("speaker"),
            filter=filter_obj,
            mapped_fields=["user_id", "point_of_order"],
        )
        for speaker in speakers.values():
            if speaker["user_id"] == instance["user_id"] and bool(
                speaker.get("point_of_order")
            ) == bool(instance.get("point_of_order")):
                raise ActionException(
                    f"User {instance['user_id']} is already on the list of speakers."
                )
        return super().validate_fields(instance)

        Checks
        - that only the requesting user can file a point-of-order
        - that a new speaker does not already exist on the list of speaker as
        waiting speaker (with begin_time == None), but allows one additional with point_of_order speaker per user
        - that points_of_order are used in this meeting
        - that user has to be present to be added to the list of speakers
        - that request-user cannot create a speaker without being point_of_order, a not closed los is closed and no list_of_speakers.can_manage permission
        
Checks
that only the requesting user can file a point-of-order
that a new speaker does not already exist on the list of speaker as
waiting speaker (with begin_time == None), but allows one additional with point_of_order speaker per user
that points_of_order are used in this meeting
that user has to be present to be added to the list of speakers
that request-user cannot create a speaker without being point_of_order, a not closed los is closed and no list_of_speakers.can_manage permission
Checks that only the requesting user can file a point - of - order that a new speaker does not already exist on the list of speaker as waiting speaker ( with begin_time == None ) but allows one additional with point_of_order speaker per user that points_of_order are used in this meeting that user has to be present to be added to the list of speakers that request - user cannot create a speaker without being point_of_order a not closed los is closed and no list_of_speakers . can_manage permission
def validate_fields(self, instance: Dict[str, Any]) -> Dict[str, Any]:
        if instance.get("point_of_order") and instance.get("user_id") != self.user_id:
            raise ActionException(
                f"The requesting user {self.user_id} is not the user {instance.get('user_id')} the point-of-order is filed for."
            )
        los_fqid = FullQualifiedId(
            Collection("list_of_speakers"), instance["list_of_speakers_id"]
        )
        los = self.datastore.get(los_fqid, ["meeting_id", "closed"])
        meeting_id = los["meeting_id"]
        meeting_fqid = FullQualifiedId(Collection("meeting"), meeting_id)
        meeting = self.datastore.get(
            meeting_fqid,
            [
                "list_of_speakers_enable_point_of_order_speakers",
                "list_of_speakers_present_users_only",
            ],
        )
        if instance.get("point_of_order") and not meeting.get(
            "list_of_speakers_enable_point_of_order_speakers"
        ):
            raise ActionException(
                "Point of order speakers are not enabled for this meeting."
            )
        if (
            not instance.get("point_of_order")
            and los.get("closed")
            and instance.get("user_id") == self.user_id
            and not has_perm(
                self.datastore,
                self.user_id,
                Permissions.ListOfSpeakers.CAN_MANAGE,
                meeting_id,
            )
        ):
            raise ActionException("The list of speakers is closed.")
        if meeting.get("list_of_speakers_present_users_only"):
            user_fqid = FullQualifiedId(Collection("user"), instance["user_id"])
            user = self.datastore.get(user_fqid, ["is_present_in_meeting_ids"])
            if meeting_id not in user.get("is_present_in_meeting_ids", ()):
                raise ActionException(
                    "Only present users can be on the lists of speakers."
                )
        filter_obj = And(
            FilterOperator("list_of_speakers_id", "=", instance["list_of_speakers_id"]),
            FilterOperator("begin_time", "=", None),
        )
        speakers = self.datastore.filter(
            collection=Collection("speaker"),
            filter=filter_obj,
            mapped_fields=["user_id", "point_of_order"],
        )
        for speaker in speakers.values():
            if speaker["user_id"] == instance["user_id"] and bool(
                speaker.get("point_of_order")
            ) == bool(instance.get("point_of_order")):
                raise ActionException(
                    f"User {instance['user_id']} is already on the list of speakers."
                )
        return super().validate_fields(instance)
def validate_fields ( self , instance : Dict [ str , Any ] ) -> Dict [ str , Any ] : if instance . get ( "point_of_order" ) and instance . get ( "user_id" ) != self . user_id : raise ActionException ( f"The requesting user {self.user_id} is not the user {instance.get('user_id')} the point-of-order is filed for." ) los_fqid = FullQualifiedId ( Collection ( "list_of_speakers" ) , instance [ "list_of_speakers_id" ] ) los = self . datastore . get ( los_fqid , [ "meeting_id" , "closed" ] ) meeting_id = los [ "meeting_id" ] meeting_fqid = FullQualifiedId ( Collection ( "meeting" ) , meeting_id ) meeting = self . datastore . get ( meeting_fqid , [ "list_of_speakers_enable_point_of_order_speakers" , "list_of_speakers_present_users_only" , ] , ) if instance . get ( "point_of_order" ) and not meeting . get ( "list_of_speakers_enable_point_of_order_speakers" ) : raise ActionException ( "Point of order speakers are not enabled for this meeting." ) if ( not instance . get ( "point_of_order" ) and los . get ( "closed" ) and instance . get ( "user_id" ) == self . user_id and not has_perm ( self . datastore , self . user_id , Permissions . ListOfSpeakers . CAN_MANAGE , meeting_id , ) ) : raise ActionException ( "The list of speakers is closed." ) if meeting . get ( "list_of_speakers_present_users_only" ) : user_fqid = FullQualifiedId ( Collection ( "user" ) , instance [ "user_id" ] ) user = self . datastore . get ( user_fqid , [ "is_present_in_meeting_ids" ] ) if meeting_id not in user . get ( "is_present_in_meeting_ids" , ( ) ) : raise ActionException ( "Only present users can be on the lists of speakers." ) filter_obj = And ( FilterOperator ( "list_of_speakers_id" , "=" , instance [ "list_of_speakers_id" ] ) , FilterOperator ( "begin_time" , "=" , None ) , ) speakers = self . datastore . filter ( collection = Collection ( "speaker" ) , filter = filter_obj , mapped_fields = [ "user_id" , "point_of_order" ] , ) for speaker in speakers . values ( ) : if speaker [ "user_id" ] == instance [ "user_id" ] and bool ( speaker . get ( "point_of_order" ) ) == bool ( instance . get ( "point_of_order" ) ) : raise ActionException ( f"User {instance['user_id']} is already on the list of speakers." ) return super ( ) . validate_fields ( instance )
Checks
 that only the requesting user can file a point-of-order
 that a new speaker does not already exist on the list of speaker as
waiting speaker (with begin_time == None), but allows one additional with point_of_order speaker per user
 that points_of_order are used in this meeting
 that user has to be present to be added to the list of speakers
 that request-user cannot create a speaker without being point_of_order, a not closed los is closed and no list_of_speakers.can_manage permission
Checks that only the requesting user can file a point - of - order that a new speaker does not already exist on the list of speaker as waiting speaker ( with begin_time == None ) but allows one additional with point_of_order speaker per user that points_of_order are used in this meeting that user has to be present to be added to the list of speakers that request - user cannot create a speaker without being point_of_order a not closed los is closed and no list_of_speakers . can_manage permission
"""
        Checks
        - that only the requesting user can file a point-of-order
        - that a new speaker does not already exist on the list of speaker as
        waiting speaker (with begin_time == None), but allows one additional with point_of_order speaker per user
        - that points_of_order are used in this meeting
        - that user has to be present to be added to the list of speakers
        - that request-user cannot create a speaker without being point_of_order, a not closed los is closed and no list_of_speakers.can_manage permission
        """ # Results are necessary, because of getting a lock_result
self
instance
Dict[str, Any]