本文整理汇总了Python中account.models.UserProfile.reputation方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.reputation方法的具体用法?Python UserProfile.reputation怎么用?Python UserProfile.reputation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.reputation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recalculate_reputation
# 需要导入模块: from account.models import UserProfile [as 别名]
# 或者: from account.models.UserProfile import reputation [as 别名]
def recalculate_reputation(profile: UserProfile):
comments = Comment.objects.filter(author=profile)
photos = Photo.objects.filter(author=profile)
reactions = Reaction.objects.filter(author=profile).count()
reputation = 0
for comment in comments:
reputation += comment.experience
for photo in photos:
reputation += photo.experience
reputation += reactions
items = Item.objects.filter(author=profile)
for item in items:
reputation += 5
if item.ratings.count() > 5:
reputation += 5
if item.comments.count() > 5:
reputation += 5
if item.photos.count() > 5:
reputation += 5
if item.flags > 5:
reputation -= 15
if 0 < item.flags <= 5:
reputation -= 5
profile.reputation = reputation
profile.save()