本文整理匯總了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()