def contest(request, contest_id):
contest = get_object_or_404(models.Contest, pk=contest_id)
if not contest.is_visible_in_list:
has_access = (request.user.is_authenticated() and
(request.user.is_staff or contest.is_user_participating(request.user)))
if not has_access:
return HttpResponseNotFound()
participants = contest.participants.filter(is_approved=True)
news = contest.news.order_by('-publish_time')
if not request.user.is_staff:
news = news.filter(is_published=True)
return render(request, 'contests/contest.html', {
'current_contest': contest,
'contest': contest,
'news': news,
'participants': participants,
})
评论列表
文章目录