models.py 文件源码

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

项目:Bitpoll 作者: fsinfuhh 项目源码 文件源码
def can_edit(self, user: BitpollUser, request: HttpRequest=None) -> bool:
        """
        check if the user can edit this Poll

        :param user: The user to edit the Poll
        :param request:  The request object,
                if this is set a error message will be emitted via the django.messages framework
        :return:
        """
        has_owner = self.group or self.user
        is_owner = self.is_owner(user)

        can_edit = ((not has_owner) or is_owner) and user.is_authenticated or not has_owner
        if request and not can_edit:
            messages.error(
                request, _("You are not allowed to edit this Poll.")
            )
        return can_edit
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号