models.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:django-rest-messaging 作者: raphaelgyory 项目源码 文件源码
def add_participants(self, request, *participants_ids):
        """
        Ensures the current user has the authorization to add the participants.
        By default, a user can add a participant if he himself is a participant.
        A callback can be added in the settings here.
        """
        participants_ids_returned_by_callback = getattr(settings, 'REST_MESSAGING_ADD_PARTICIPANTS_CALLBACK', self._limit_participants)(request, *participants_ids)
        participations = []
        ids = []
        for participant_id in participants_ids_returned_by_callback:
            participations.append(Participation(participant_id=participant_id, thread=self))
            ids.append(participant_id)

        Participation.objects.bulk_create(participations)
        post_save.send(Thread, instance=self, created=True, created_and_add_participants=True, request_participant_id=request.rest_messaging_participant.id)

        return ids
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号