当前位置: 首页>>代码示例>>Python>>正文


Python Feed.user方法代码示例

本文整理汇总了Python中models.Feed.user方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.user方法的具体用法?Python Feed.user怎么用?Python Feed.user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Feed的用法示例。


在下文中一共展示了Feed.user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: refresh_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import user [as 别名]
def refresh_feed():
    questions = Question.objects.filter(is_new=1)
    users = User.objects.all()
    for q in questions:
        if not q.group or q.group.membership == 2:
            for u in users:
                if exists_in_feed(q, u):
                    continue
                # score = poll_score(q, u)
                score = 10
                feed = Feed()
                feed.user = u
                feed.question = q
                feed.score = score
                feed.save()
        elif q.group.id == 1:
            for u in q.user.userprofile.friends:
                if exists_in_feed(q, u):
                    continue
                # score = poll_score(q, u)
                score = 50
                feed = Feed()
                feed.user = u
                feed.question = q
                feed.score = score
                feed.save()

            # Allow the question creator to vote also
            Feed(user=q.user, question=q, score=50).save()

        else:
            group = Group.objects.get(pk=q.group.id)
            for u in [x.user for x in group.member_set.filter(pending=0)]: # private group
                if exists_in_feed(q, u):
                    continue
                score = 30
                feed = Feed()
                feed.user = u
                feed.question = q
                feed.score = score
                feed.save()
            for u in [x.user for x in group.openmember_set.all()]: # public group
                if exists_in_feed(q, u):
                    continue
                score = 20
                feed = Feed()
                feed.user = u
                feed.question = q
                feed.score = score
                feed.save()

        q.is_new = 0
        q.save()
开发者ID:krdeepak,项目名称:djmysite,代码行数:55,代码来源:util.py

示例2: create_feed_new_user

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import user [as 别名]
def create_feed_new_user(user):
    questions = Question.objects.all()[:1000]
    for q in questions:
        if not q.group:
            score = 10
            feed = Feed()
            feed.user = user
            feed.question = q
            feed.score = score
            feed.save()
        elif q.group.id == 1:
            if q.user.id in [x.id for x in user.userprofile.friends]:
                # score = poll_score(q, u)
                score = 50
                feed = Feed()
                feed.user = user
                feed.question = q
                feed.score = score
                feed.save()
        else:
            # new user not added to any group just after joining
            pass
开发者ID:krdeepak,项目名称:djmysite,代码行数:24,代码来源:util.py


注:本文中的models.Feed.user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。