本文整理汇总了Python中mkt.reviewers.models.ReviewerScore.award_moderation_points方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.award_moderation_points方法的具体用法?Python ReviewerScore.award_moderation_points怎么用?Python ReviewerScore.award_moderation_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.reviewers.models.ReviewerScore
的用法示例。
在下文中一共展示了ReviewerScore.award_moderation_points方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_breakdown
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_breakdown(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
breakdown = ReviewerScore.get_breakdown(self.user)
eq_(len(breakdown), 1)
eq_(set([b.atype for b in breakdown]),
set([amo.ADDON_WEBAPP]))
示例2: test_get_performance_since
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_performance_since(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
rs = list(ReviewerScore.objects.all())
rs[0].update(created=self.days_ago(50))
performance = ReviewerScore.get_performance_since(self.user, self.days_ago(30))
eq_(len(performance), 1)
示例3: moderatelog_detail
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def moderatelog_detail(request, eventlog_id):
log = get_object_or_404(
ActivityLog.objects.editor_events(), pk=eventlog_id)
review = None
if len(log.arguments) > 1 and isinstance(log.arguments[1], Review):
review = log.arguments[1]
form = ModerateLogDetailForm(request.POST or None)
is_admin = acl.action_allowed(request, 'ReviewerAdminTools', 'View')
can_undelete = review and review.deleted and (
is_admin or request.user.pk == log.user.pk)
if (request.method == 'POST' and form.is_valid() and
form.cleaned_data['action'] == 'undelete'):
if not can_undelete:
if not review:
raise RuntimeError('Review doesn`t exist.')
elif not review.deleted:
raise RuntimeError('Review isn`t deleted.')
else:
raise PermissionDenied
ReviewerScore.award_moderation_points(
log.user, review.addon, review.id, undo=True)
review.undelete()
return redirect('reviewers.apps.moderatelog.detail', eventlog_id)
data = context(request, log=log, form=form, review=review,
can_undelete=can_undelete)
return render(request, 'reviewers/moderatelog_detail.html', data)
示例4: test_get_breakdown_since
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_breakdown_since(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
rs = list(ReviewerScore.objects.all())
rs[0].update(created=self.days_ago(50))
breakdown = ReviewerScore.get_breakdown_since(self.user,
self.days_ago(30))
eq_(len(breakdown), 1)
eq_([b.atype for b in breakdown], [rs[1].addon.type])
示例5: test_get_leaderboards_last
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_leaderboards_last(self):
users = []
for i in range(6):
users.append(UserProfile.objects.create(username='user-%s' % i))
last_user = users.pop(len(users) - 1)
for u in users:
self._give_points(user=u)
# Last user gets lower points by a moderation review.
ReviewerScore.award_moderation_points(last_user, self.app, 1)
leaders = ReviewerScore.get_leaderboards(last_user)
eq_(leaders['user_rank'], 6)
eq_(len(leaders['leader_top']), 3)
eq_(len(leaders['leader_near']), 2)
示例6: test_award_moderation_points
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_award_moderation_points(self):
ReviewerScore.award_moderation_points(self.user, self.app, 1)
score = ReviewerScore.objects.all()[0]
eq_(score.score, mkt.REVIEWED_SCORES.get(mkt.REVIEWED_APP_REVIEW))
eq_(score.note_key, mkt.REVIEWED_APP_REVIEW)
ReviewerScore.award_moderation_points(self.user, self.app, 1, undo=True)
score = ReviewerScore.objects.all()[1]
eq_(score.score, mkt.REVIEWED_SCORES.get(mkt.REVIEWED_APP_REVIEW_UNDO))
eq_(score.note_key, mkt.REVIEWED_APP_REVIEW_UNDO)
# If we change the _UNDO score to be different this test will fail.
eq_(ReviewerScore.get_total(self.user), 0)
示例7: test_get_leaderboards_last
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_leaderboards_last(self):
users = []
for i in range(6):
users.append(user_factory())
last_user = users.pop(len(users) - 1)
for u in users:
self._give_points(user=u)
# Last user gets lower points by a moderation review.
ReviewerScore.award_moderation_points(last_user, self.app, 1)
leaders = ReviewerScore.get_leaderboards(last_user)
eq_(leaders["user_rank"], 6)
eq_(len(leaders["leader_top"]), 3)
eq_(len(leaders["leader_near"]), 2)
示例8: save
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def save(self):
for form in self.forms:
if form.cleaned_data and user_can_delete_review(self.request, form.instance):
action = int(form.cleaned_data["action"])
is_flagged = form.instance.reviewflag_set.count() > 0
if action != REVIEW_MODERATE_SKIP: # Delete flags.
for flag in form.instance.reviewflag_set.all():
flag.delete()
review = form.instance
webapp = review.webapp
if action == REVIEW_MODERATE_DELETE:
review.delete()
mkt.log(
mkt.LOG.DELETE_REVIEW,
webapp,
review,
details=dict(
title=unicode(review.title),
body=unicode(review.body),
webapp_id=webapp.id,
webapp_title=unicode(webapp.name),
is_flagged=is_flagged,
),
)
if self.request:
ReviewerScore.award_moderation_points(self.request.user, webapp, review.id)
elif action == REVIEW_MODERATE_KEEP:
review.editorreview = False
review.save()
mkt.log(
mkt.LOG.APPROVE_REVIEW,
webapp,
review,
details=dict(
title=unicode(review.title),
body=unicode(review.body),
webapp_id=webapp.id,
webapp_title=unicode(webapp.name),
is_flagged=is_flagged,
),
)
if self.request:
ReviewerScore.award_moderation_points(self.request.user, webapp, review.id)
示例9: save
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def save(self):
for form in self.forms:
if form.cleaned_data and user_can_delete_review(self.request,
form.instance):
action = int(form.cleaned_data['action'])
is_flagged = (form.instance.reviewflag_set.count() > 0)
if action != REVIEW_MODERATE_SKIP: # Delete flags.
for flag in form.instance.reviewflag_set.all():
flag.delete()
review = form.instance
addon = review.addon
if action == REVIEW_MODERATE_DELETE:
review_addon = review.addon
review_id = review.id
review.delete()
amo.log(amo.LOG.DELETE_REVIEW, review_addon, review_id,
details=dict(title=unicode(review.title),
body=unicode(review.body),
addon_id=addon.id,
addon_title=unicode(addon.name),
is_flagged=is_flagged))
if self.request:
ReviewerScore.award_moderation_points(
self.request.user, addon, review_id)
elif action == REVIEW_MODERATE_KEEP:
review.editorreview = False
review.save()
amo.log(amo.LOG.APPROVE_REVIEW, review.addon, review,
details=dict(title=unicode(review.title),
body=unicode(review.body),
addon_id=addon.id,
addon_title=unicode(addon.name),
is_flagged=is_flagged))
if self.request:
ReviewerScore.award_moderation_points(
self.request.user, addon, review.id)
示例10: test_award_moderation_points
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_award_moderation_points(self):
ReviewerScore.award_moderation_points(self.user, self.app, 1)
score = ReviewerScore.objects.all()[0]
eq_(score.score, amo.REVIEWED_SCORES.get(amo.REVIEWED_APP_REVIEW))
eq_(score.note_key, amo.REVIEWED_APP_REVIEW)
示例11: test_get_performance
# 需要导入模块: from mkt.reviewers.models import ReviewerScore [as 别名]
# 或者: from mkt.reviewers.models.ReviewerScore import award_moderation_points [as 别名]
def test_get_performance(self):
self._give_points()
ReviewerScore.award_moderation_points(self.user, self.app, 1)
performance = ReviewerScore.get_performance(self.user)
eq_(len(performance), 1)