Esempio n. 1
0
    def approve_content(self):
        """Approve content of an add-on."""
        channel = self.version.channel
        version = self.addon.current_version

        # Content review only action.
        assert self.content_review

        # Doesn't make sense for unlisted versions.
        assert channel == amo.RELEASE_CHANNEL_LISTED

        # Like confirm auto approval, the approve content 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'] = ''

        # When doing a content review, don't increment the approvals 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)

        # Assign reviewer incentive scores.
        if self.human_review:
            is_post_review = channel == amo.RELEASE_CHANNEL_LISTED
            ReviewerScore.award_points(self.user,
                                       self.addon,
                                       self.addon.status,
                                       version=version,
                                       post_review=is_post_review,
                                       content_review=self.content_review)
Esempio n. 2
0
    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)
Esempio n. 3
0
def content_approve_migrated_themes(ids, **kw):
    log.info(
        '[%s@None] Marking migrated static themes as content-reviewed %s.' %
        (len(ids), ids))
    addons = Addon.objects.filter(pk__in=ids)
    for addon in addons:
        try:
            migrated_date = MigratedLWT.objects.get(static_theme=addon).created
        except MigratedLWT.DoesNotExist:
            continue
        AddonApprovalsCounter.approve_content_for_addon(addon=addon,
                                                        now=migrated_date)
Esempio n. 4
0
    def test_basic(self):
        # Pretend those 3 static themes were migrated. Only the first one
        # should be marked as content approved by the command.
        static_theme = addon_factory(type=amo.ADDON_STATICTHEME)
        static_theme_already_content_approved = addon_factory(
            type=amo.ADDON_STATICTHEME)
        static_theme_not_public = addon_factory(
            type=amo.ADDON_STATICTHEME, status=amo.STATUS_NOMINATED)
        AddonApprovalsCounter.approve_content_for_addon(
            static_theme_already_content_approved)
        migrated_themes = [
            static_theme,
            static_theme_already_content_approved,
            static_theme_not_public
        ]
        migration_date = self.days_ago(123)
        for addon in migrated_themes:
            MigratedLWT.objects.create(
                static_theme=addon,
                lightweight_theme=addon_factory(type=amo.ADDON_PERSONA),
                created=migration_date)
        # Add another that never went through migration, it was born that way.
        non_migrated_theme = addon_factory(type=amo.ADDON_STATICTHEME)

        call_command('process_addons', task='content_approve_migrated_themes')

        approvals_info = AddonApprovalsCounter.objects.get(addon=static_theme)
        assert approvals_info.last_content_review == migration_date

        approvals_info = AddonApprovalsCounter.objects.get(
            addon=static_theme_already_content_approved)
        assert approvals_info.last_content_review != migration_date
        self.assertCloseToNow(approvals_info.last_content_review)

        assert not AddonApprovalsCounter.objects.filter(
            addon=non_migrated_theme).exists()

        assert not AddonApprovalsCounter.objects.filter(
            addon=static_theme_not_public).exists()
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)