本文整理汇总了Python中mkt.reviewers.models.ReviewerScore类的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore类的具体用法?Python ReviewerScore怎么用?Python ReviewerScore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReviewerScore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_performance_since
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)
示例2: moderatelog_detail
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)
示例3: test_get_breakdown
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]))
示例4: test_get_total
def test_get_total(self):
user2 = UserProfile.objects.get(email="[email protected]")
self._give_points()
self._give_points()
self._give_points(user=user2)
eq_(ReviewerScore.get_total(self.user), mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED] * 2)
eq_(ReviewerScore.get_total(user2), mkt.REVIEWED_SCORES[mkt.REVIEWED_WEBAPP_HOSTED])
示例5: reviewers_score_bar
def reviewers_score_bar(context, types=None):
user = context.get('user')
return new_context(dict(
request=context.get('request'),
mkt=mkt, settings=settings,
points=ReviewerScore.get_recent(user),
total=ReviewerScore.get_total(user),
**ReviewerScore.get_leaderboards(user, types=types)))
示例6: test_get_breakdown_since
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])
示例7: test_award_moderation_points
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)
示例8: test_get_leaderboards_last
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)
示例9: test_get_leaderboards_last
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)
示例10: reviewers_score_bar
def reviewers_score_bar(context, types=None, addon_type=None):
user = context.get("amo_user")
return new_context(
dict(
request=context.get("request"),
amo=amo,
settings=settings,
points=ReviewerScore.get_recent(user, addon_type=addon_type),
total=ReviewerScore.get_total(user),
**ReviewerScore.get_leaderboards(user, types=types, addon_type=addon_type)
)
)
示例11: process_reject
def process_reject(self):
"""
Reject an app.
Changes status to Rejected.
Creates Rejection note.
"""
# Hold onto the status before we change it.
status = self.addon.status
self.set_files(mkt.STATUS_DISABLED, self.version.files.all(),
hide_disabled_file=True)
# If this app is not packaged (packaged apps can have multiple
# versions) or if there aren't other versions with already reviewed
# files, reject the app also.
if (not self.addon.is_packaged or
not self.addon.versions.exclude(id=self.version.id)
.filter(files__status__in=mkt.REVIEWED_STATUSES).exists()):
self.set_addon(status=mkt.STATUS_REJECTED)
if self.in_escalate:
EscalationQueue.objects.filter(addon=self.addon).delete()
if self.in_rereview:
RereviewQueue.objects.filter(addon=self.addon).delete()
self.create_note(mkt.LOG.REJECT_VERSION)
log.info(u'Making %s disabled' % self.addon)
# Assign reviewer incentive scores.
return ReviewerScore.award_points(self.request.user, self.addon,
status, in_rereview=self.in_rereview)
示例12: process_public
def process_public(self):
"""
Makes an app public or approved.
Changes status to Public/Public Waiting.
Creates Approval note/email.
"""
if self.addon.has_incomplete_status():
# Failsafe.
return
# Hold onto the status before we change it.
status = self.addon.status
if self.addon.make_public == amo.PUBLIC_IMMEDIATELY:
self._process_public_immediately()
else:
self._process_approved()
if self.in_escalate:
EscalationQueue.objects.filter(addon=self.addon).delete()
# Clear priority_review flag on approval - its not persistant.
if self.addon.priority_review:
self.addon.update(priority_review=False)
# Assign reviewer incentive scores.
return ReviewerScore.award_points(self.request.amo_user, self.addon,
status)
示例13: save
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)
示例14: performance
def performance(request, username=None):
is_admin = acl.action_allowed(request, 'Admin', '%')
if username:
if username == request.amo_user.username:
user = request.amo_user
elif is_admin:
user = get_object_or_404(UserProfile, username=username)
else:
raise http.Http404
else:
user = request.amo_user
today = datetime.date.today()
month_ago = today - datetime.timedelta(days=30)
year_ago = today - datetime.timedelta(days=365)
total = ReviewerScore.get_total(user)
totals = ReviewerScore.get_breakdown(user)
months = ReviewerScore.get_breakdown_since(user, month_ago)
years = ReviewerScore.get_breakdown_since(user, year_ago)
def _sum(iter, types):
return sum(s.total for s in iter if s.atype in types)
breakdown = {
'month': {
'addons': _sum(months, amo.GROUP_TYPE_ADDON),
'apps': _sum(months, amo.GROUP_TYPE_WEBAPP),
},
'year': {
'addons': _sum(years, amo.GROUP_TYPE_ADDON),
'apps': _sum(years, amo.GROUP_TYPE_WEBAPP),
},
'total': {
'addons': _sum(totals, amo.GROUP_TYPE_ADDON),
'apps': _sum(totals, amo.GROUP_TYPE_WEBAPP),
}
}
ctx = context(request, **{
'profile': user,
'total': total,
'breakdown': breakdown,
})
return render(request, 'reviewers/performance.html', ctx)
示例15: save
def save(self):
for form in self.forms:
if form.cleaned_data:
action = int(form.cleaned_data['action'])
if action == ABUSE_REPORT_SKIP:
continue
inst = form.instance
app = None
site = None
user = None
texts = []
for report in inst.abuse_reports.all().filter(read=False):
report.read = True
report.save()
app = report.addon
site = report.website
user = report.user
if report.message:
texts.append(report.message)
if app:
mkt.log(mkt.LOG.APP_ABUSE_MARKREAD, app, report,
details=dict(
body=unicode(report.message),
addon_id=app.id,
addon_title=unicode(app.name)
))
elif user:
# Not possible on Marketplace currently.
pass
elif site:
mkt.log(mkt.LOG.WEBSITE_ABUSE_MARKREAD, site,
report,
details=dict(
body=unicode(report.message),
website_id=site.id,
website_title=unicode(site.name)
))
if app or site:
ReviewerScore.award_mark_abuse_points(
self.request.user, addon=app, website=site)
if app and action == ABUSE_REPORT_FLAG:
message = _('Abuse reports needing investigation: %s' %
(', '.join(texts)))
RereviewQueue.flag(
app, mkt.LOG.REREVIEW_ABUSE_APP, message=message)