views.py 文件源码

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

项目:Ares 作者: tehpug 项目源码 文件源码
def get_context_data(self, **kwargs):
        """
        Manipulating template context 
        """
        ctx = super(LeagueDetail, self).get_context_data(**kwargs)
        now = timezone.localtime()
        ctx['is_registered'] = False
        ctx['is_expired'] = False
        ctx['is_full'] = self.object.robots.count() == self.object.num_robots
        if self.request.user.is_authenticated():
            ctx['is_registered'] = self.object.robots.filter(
                user=self.request.user).count() > 0
        if now > self.object.registration_end or \
                now < self.object.registration_start:
            ctx['is_expired'] = True

        if ctx['is_expired']:
            ctx['table'] = League.get_table()

        return ctx
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号