本文整理汇总了Python中olympia.reviewers.models.ReviewerScore.award_points方法的典型用法代码示例。如果您正苦于以下问题:Python ReviewerScore.award_points方法的具体用法?Python ReviewerScore.award_points怎么用?Python ReviewerScore.award_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类olympia.reviewers.models.ReviewerScore
的用法示例。
在下文中一共展示了ReviewerScore.award_points方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_auto_approved
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def confirm_auto_approved(self):
"""Confirm an auto-approval decision.
We don't need to really store that information, what we care about
is logging something for future reviewers to be aware of, and, if the
version is listed, incrementing AddonApprovalsCounter, which also
resets the last human review date to now, and log it so that it's
displayed later in the review page."""
status = self.addon.status
latest_version = self.version
# The confirm auto-approval action should not show the comment box,
# so override the text in case the reviewer switched between actions
# and accidently submitted some comments from another action.
self.data['comments'] = ''
if self.content_review_only:
# If we're only doing a content review, then don't increment
# the counter, just record the date of the content approval
# and log it.
AddonApprovalsCounter.approve_content_for_addon(addon=self.addon)
self.log_action(amo.LOG.APPROVE_CONTENT)
else:
if self.version.channel == amo.RELEASE_CHANNEL_LISTED:
self.version.autoapprovalsummary.update(confirmed=True)
AddonApprovalsCounter.increment_for_addon(addon=self.addon)
self.log_action(amo.LOG.CONFIRM_AUTO_APPROVED)
# Assign reviewer incentive scores.
if self.request:
ReviewerScore.award_points(
self.request.user, self.addon, status, version=latest_version,
post_review=True, content_review=self.content_review_only)
示例2: process_sandbox
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def process_sandbox(self):
"""Set an addon or a version back to sandbox."""
# Safeguard to force implementation for unlisted add-ons to completely
# override this method.
assert self.version.channel == amo.RELEASE_CHANNEL_LISTED
# Safeguard to make sure this action is not used for content review
# (it should use reject_multiple_versions instead).
assert not self.content_review_only
# Hold onto the status before we change it.
status = self.addon.status
if self.set_addon_status:
self.set_addon(status=amo.STATUS_NULL)
self.set_files(amo.STATUS_DISABLED, self.files,
hide_disabled_file=True)
self.log_action(amo.LOG.REJECT_VERSION)
template = u'%s_to_sandbox' % self.review_type
subject = u'Mozilla Add-ons: %s %s didn\'t pass review'
self.notify_email(template, subject)
self.log_sandbox_message()
log.info(u'Sending email for %s' % (self.addon))
# Assign reviewer incentive scores.
if self.request:
ReviewerScore.award_points(
self.request.user, self.addon, status, version=self.version)
示例3: award_all_points_for_action
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def award_all_points_for_action(self, action, content_review=False):
for activity_log in ActivityLog.objects.filter(action=action.id):
user = activity_log.user
try:
addon = activity_log.arguments[0]
version = activity_log.arguments[1]
except IndexError:
log.error('ActivityLog %d is missing one or more arguments',
activity_log.pk)
continue
# If there is already a score recorded in the database for this
# event, with our special note, it means we already processed it
# somehow (maybe we ran the script twice...), so ignore it.
# Otherwise award the points!
event = ReviewerScore.get_event(
addon, amo.STATUS_PUBLIC, version=version,
post_review=True, content_review=content_review)
if not ReviewerScore.objects.filter(
user=user, addon=addon, note_key=event,
note=MANUAL_NOTE).exists():
ReviewerScore.award_points(
user, addon, amo.STATUS_PUBLIC,
version=version, post_review=True,
content_review=content_review, extra_note=MANUAL_NOTE)
else:
log.error('Already awarded points for "%s" action on %s %s',
action.short, addon, version)
continue
示例4: create_and_review_addon
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def create_and_review_addon(self, user, weight, verdict, content_review):
addon = addon_factory()
AutoApprovalSummary.objects.create(
version=addon.current_version, verdict=verdict, weight=weight)
ReviewerScore.award_points(
user, addon, addon.status, version=addon.versions.all()[0],
post_review=True, content_review=content_review)
示例5: process_public
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def process_public(self):
"""Set an add-on or a version to public."""
# Safeguard to force implementation for unlisted add-ons to completely
# override this method.
assert self.version.channel == amo.RELEASE_CHANNEL_LISTED
# Safeguard to make sure this action is not used for content review
# (it should use confirm_auto_approved instead).
assert not self.content_review_only
# Sign addon.
for file_ in self.files:
sign_file(file_)
# Hold onto the status before we change it.
status = self.addon.status
# Save files first, because set_addon checks to make sure there
# is at least one public file or it won't make the addon public.
self.set_files(amo.STATUS_PUBLIC, self.files)
if self.set_addon_status:
self.set_addon(status=amo.STATUS_PUBLIC)
# If we've approved a webextension, add a tag identifying them as such.
if any(file_.is_webextension for file_ in self.files):
Tag(tag_text='firefox57').save_tag(self.addon)
# If we've approved a mozilla signed add-on, add the firefox57 tag
if all(file_.is_mozilla_signed_extension for file_ in self.files):
Tag(tag_text='firefox57').save_tag(self.addon)
# Increment approvals counter if we have a request (it means it's a
# human doing the review) otherwise reset it as it's an automatic
# approval.
if self.request:
AddonApprovalsCounter.increment_for_addon(addon=self.addon)
else:
AddonApprovalsCounter.reset_for_addon(addon=self.addon)
self.log_action(amo.LOG.APPROVE_VERSION)
template = u'%s_to_public' % self.review_type
if self.review_type == 'pending':
subject = u'Mozilla Add-ons: %s %s Updated'
else:
subject = u'Mozilla Add-ons: %s %s Approved'
self.notify_email(template, subject)
self.log_public_message()
log.info(u'Sending email for %s' % (self.addon))
# Assign reviewer incentive scores.
if self.request:
ReviewerScore.award_points(
self.request.user, self.addon, status, version=self.version)
示例6: save
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def save(self):
action = self.cleaned_data['action']
comment = self.cleaned_data.get('comment')
reject_reason = self.cleaned_data.get('reject_reason')
theme = self.cleaned_data['theme']
is_rereview = (
theme.rereviewqueuetheme_set.exists() and
theme.addon.status not in (amo.STATUS_PENDING,
amo.STATUS_REVIEW_PENDING))
theme_lock = ThemeLock.objects.get(theme=self.cleaned_data['theme'])
mail_and_log = True
if action == amo.ACTION_APPROVE:
if is_rereview:
approve_rereview(theme)
theme.addon.update(status=amo.STATUS_PUBLIC)
theme.approve = datetime.datetime.now()
theme.save()
elif action in (amo.ACTION_REJECT, amo.ACTION_DUPLICATE):
if is_rereview:
reject_rereview(theme)
else:
theme.addon.update(status=amo.STATUS_REJECTED)
elif action == amo.ACTION_FLAG:
if is_rereview:
mail_and_log = False
else:
theme.addon.update(status=amo.STATUS_REVIEW_PENDING)
elif action == amo.ACTION_MOREINFO:
if not is_rereview:
theme.addon.update(status=amo.STATUS_REVIEW_PENDING)
if mail_and_log:
send_mail(self.cleaned_data, theme_lock)
# Log.
ActivityLog.create(
amo.LOG.THEME_REVIEW, theme.addon, details={
'theme': theme.addon.name.localized_string,
'action': action,
'reject_reason': reject_reason,
'comment': comment}, user=theme_lock.reviewer)
log.info('%sTheme %s (%s) - %s' % (
'[Rereview] ' if is_rereview else '', theme.addon.name,
theme.id, action))
score = 0
if action in (amo.ACTION_REJECT, amo.ACTION_DUPLICATE,
amo.ACTION_APPROVE):
score = ReviewerScore.award_points(
theme_lock.reviewer, theme.addon, theme.addon.status)
theme_lock.delete()
return score
示例7: reject_multiple_versions
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def reject_multiple_versions(self):
"""Reject a list of versions."""
# self.version and self.files won't point to the versions we want to
# modify in this action, so set them to None before finding the right
# versions.
status = self.addon.status
latest_version = self.version
self.version = None
self.files = None
action_id = (amo.LOG.REJECT_CONTENT if self.content_review_only
else amo.LOG.REJECT_VERSION)
timestamp = datetime.now()
for version in self.data['versions']:
files = version.files.all()
self.set_files(amo.STATUS_DISABLED, files, hide_disabled_file=True)
self.log_action(action_id, version=version, files=files,
timestamp=timestamp)
self.addon.update_status()
self.data['version_numbers'] = u', '.join(
six.text_type(v.version) for v in self.data['versions'])
# Send the email to the developer. We need to pass the latest version
# of the add-on instead of one of the versions we rejected, it will be
# used to generate a token allowing the developer to reply, and that
# only works with the latest version.
if self.addon.status != amo.STATUS_APPROVED:
template = u'reject_multiple_versions_disabled_addon'
subject = (u'Mozilla Add-ons: %s%s has been disabled on '
u'addons.mozilla.org')
else:
template = u'reject_multiple_versions'
subject = u'Mozilla Add-ons: Versions disabled for %s%s'
self.notify_email(template, subject, version=latest_version)
log.info(
u'Making %s versions %s disabled' % (
self.addon,
u', '.join(
six.text_type(v.pk) for v in self.data['versions'])))
log.info(u'Sending email for %s' % (self.addon))
# Assign reviewer incentive scores.
if self.request:
ReviewerScore.award_points(
self.request.user, self.addon, status, version=latest_version,
post_review=True, content_review=self.content_review_only)
示例8: confirm_auto_approved
# 需要导入模块: from olympia.reviewers.models import ReviewerScore [as 别名]
# 或者: from olympia.reviewers.models.ReviewerScore import award_points [as 别名]
def confirm_auto_approved(self):
"""Confirm an auto-approval decision."""
channel = self.version.channel
if channel == amo.RELEASE_CHANNEL_LISTED:
# When doing an approval in listed channel, the version we care
# about is always current_version and *not* self.version.
# This allows reviewers to confirm approval of a public add-on even
# when their latest version is disabled.
version = self.addon.current_version
else:
# For unlisted, we just use self.version.
version = self.version
# The confirm auto-approval action should not show the comment box,
# so override the text in case the reviewer switched between actions
# and accidently submitted some comments from another action.
self.data['comments'] = ''
if self.content_review_only:
# If we're only doing a content review, then don't increment
# the counter, just record the date of the content approval
# and log it.
AddonApprovalsCounter.approve_content_for_addon(addon=self.addon)
self.log_action(amo.LOG.APPROVE_CONTENT, version=version)
else:
if channel == amo.RELEASE_CHANNEL_LISTED:
version.autoapprovalsummary.update(confirmed=True)
AddonApprovalsCounter.increment_for_addon(addon=self.addon)
self.log_action(amo.LOG.CONFIRM_AUTO_APPROVED, version=version)
# Assign reviewer incentive scores.
if self.request:
is_post_review = channel == amo.RELEASE_CHANNEL_LISTED
ReviewerScore.award_points(
self.request.user, self.addon, self.addon.status,
version=version, post_review=is_post_review,
content_review=self.content_review_only)