views.py 文件源码

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

项目:drapo 作者: andgein 项目源码 文件源码
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,
    })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号