views.py 文件源码

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

项目:umklapp_site 作者: mohrm 项目源码 文件源码
def set_choices(self,user):
        """ Sets the mitspieler choices to all other non-admin users"""
        choices = []
        initial = []
        users = User.objects\
            .annotate(lastpart=Max('teller__storyparts__creation'))\
            .filter(is_superuser=False, is_active=True)\
            .exclude(id=user.id).all()
        for u in users:
            if u.lastpart:
                last_storypart_date = u.lastpart.strftime("%Y-%m-%d")
            else:
                last_storypart_date = "never"
            assert u != user and not u.is_superuser and u.is_active
            initial.append(u.pk)
            choices.append((u.pk, "%s   (last active: %s)" % (str(u), last_storypart_date)))
        self.fields['mitspieler'].choices = choices
        self.fields['mitspieler'].initial = []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号