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}))
评论列表
文章目录