本文整理汇总了Python中models.Feed.score方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.score方法的具体用法?Python Feed.score怎么用?Python Feed.score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Feed
的用法示例。
在下文中一共展示了Feed.score方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh_feed
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import score [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()
示例2: create_feed_new_user
# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import score [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