clarification.py 文件源码

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

项目:eoj3 作者: ultmaster 项目源码 文件源码
def post(self, request, cid):
        if self.contest.status != 0:
            raise PermissionDenied
        text = request.POST["text"]
        if not text or not request.user.is_authenticated:
            raise PermissionDenied
        if is_contest_manager(request.user, self.contest):
            ContestClarification.objects.create(contest=self.contest, important=True, author=request.user, answer=text)
            notify.send(sender=request.user,
                        recipient=list(map(lambda x: x.user, self.contest.contestparticipant_set.select_related("user").all())),
                        verb="posted a notification in",
                        level="warning",
                        target=self.contest,
                        description=text)
        else:
            ContestClarification.objects.create(contest=self.contest, author=request.user, text=text)
            notify.send(sender=request.user,
                        recipient=self.contest.managers.all(),
                        verb="asked a question in",
                        level="warning",
                        target=self.contest,
                        description=text)
        return redirect(reverse("contest:dashboard", kwargs={"cid": self.contest.pk}))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号