Пример #1
0
    def save(self, addon, commit=False):
        # We ignore `commit`, since we need it to be `False` so we can save
        # the ManyToMany fields on our own.
        addonform = super(AppFormBasic, self).save(commit=False)
        addonform.save()

        if 'manifest_url' in self.changed_data:
            before_url = self.old_manifest_url
            after_url = self.cleaned_data['manifest_url']

            # If a non-admin edited the manifest URL, add to Re-review Queue.
            if not acl.action_allowed(self.request, 'Admin', '%'):
                log.info(u'[Webapp:%s] (Re-review) Manifest URL changed '
                         u'from %s to %s'
                         % (self.instance, before_url, after_url))

                msg = (_(u'Manifest URL changed from {before_url} to '
                         u'{after_url}')
                       .format(before_url=before_url, after_url=after_url))

                RereviewQueue.flag(self.instance,
                                   amo.LOG.REREVIEW_MANIFEST_URL_CHANGE, msg)

            # Refetch the new manifest.
            log.info('Manifest %s refreshed for %s'
                     % (addon.manifest_url, addon))
            update_manifests.delay([self.instance.id])

        return addonform
Пример #2
0
def mark_for_rereview(addon, added_devices, removed_devices):
    msg = _(u'Device(s) changed: {0}').format(', '.join(
        [_(u'Added {0}').format(unicode(amo.DEVICE_TYPES[d].name))
         for d in added_devices] +
        [_(u'Removed {0}').format(unicode(amo.DEVICE_TYPES[d].name))
         for d in removed_devices]))
    RereviewQueue.flag(addon, amo.LOG.REREVIEW_DEVICES_ADDED, msg)
Пример #3
0
def mark_for_rereview_features_change(webapp, added_features,
                                      removed_features):
    # L10n: {0} is the list of requirements changes.
    msg = _(u'Requirements changed: {0}').format(', '.join(
        [_(u'Added {0}').format(f) for f in added_features] +
        [_(u'Removed {0}').format(f) for f in removed_features]))
    RereviewQueue.flag(webapp, mkt.LOG.REREVIEW_FEATURES_CHANGED, msg)
Пример #4
0
    def save(self, addon, commit=False):
        # We ignore `commit`, since we need it to be `False` so we can save
        # the ManyToMany fields on our own.
        addonform = super(AppFormBasic, self).save(commit=False)
        addonform.save()

        if 'manifest_url' in self.changed_data:
            before_url = self.old_manifest_url
            after_url = self.cleaned_data['manifest_url']

            # If a non-admin edited the manifest URL, add to Re-review Queue.
            if not acl.action_allowed(self.request, 'Admin', '%'):
                log.info(u'[Webapp:%s] (Re-review) Manifest URL changed '
                         u'from %s to %s' %
                         (self.instance, before_url, after_url))

                msg = (_(u'Manifest URL changed from {before_url} to '
                         u'{after_url}').format(before_url=before_url,
                                                after_url=after_url))

                RereviewQueue.flag(self.instance,
                                   amo.LOG.REREVIEW_MANIFEST_URL_CHANGE, msg)

            # Refetch the new manifest.
            log.info('Manifest %s refreshed for %s' %
                     (addon.manifest_url, addon))
            update_manifests.delay([self.instance.id])

        return addonform
Пример #5
0
def _update_manifest(id, check_hash, failed_fetches):
    webapp = Webapp.objects.get(pk=id)
    version = webapp.versions.latest()
    file_ = version.files.latest()

    _log(webapp, u'Fetching webapp manifest')
    if not file_:
        _log(webapp, u'Ignoring, no existing file')
        return

    # Fetch manifest, catching and logging any exception.
    try:
        content = _fetch_manifest(webapp.manifest_url)
    except Exception, e:
        msg = u'Failed to get manifest from %s. Error: %s' % (
            webapp.manifest_url, e)
        failed_fetches[id] = failed_fetches.get(id, 0) + 1
        if failed_fetches[id] == 3:
            # This is our 3rd attempt, let's send the developer(s) an email to
            # notify him of the failures.
            notify_developers_of_failure(webapp, u'Validation errors:\n' + msg)
        elif failed_fetches[id] >= 4:
            # This is our 4th attempt, we should already have notified the
            # developer(s). Let's put the app in the re-review queue.
            _log(webapp, msg, rereview=True, exc_info=True)
            if webapp.status in mkt.WEBAPPS_APPROVED_STATUSES:
                RereviewQueue.flag(webapp, mkt.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Пример #6
0
def mark_for_rereview(addon, added_devices, removed_devices):
    msg = _(u'Device(s) changed: {0}').format(', '.join(
        [_(u'Added {0}').format(unicode(mkt.DEVICE_TYPES[d].name))
         for d in added_devices] +
        [_(u'Removed {0}').format(unicode(mkt.DEVICE_TYPES[d].name))
         for d in removed_devices]))
    RereviewQueue.flag(addon, mkt.LOG.REREVIEW_DEVICES_ADDED, msg)
Пример #7
0
def _update_manifest(id, check_hash, failed_fetches):
    webapp = Webapp.objects.get(pk=id)
    version = webapp.versions.latest()
    file_ = version.files.latest()

    _log(webapp, u'Fetching webapp manifest')
    if not file_:
        _log(webapp, u'Ignoring, no existing file')
        return

    # Fetch manifest, catching and logging any exception.
    try:
        content = _fetch_manifest(webapp.manifest_url)
    except Exception, e:
        msg = u'Failed to get manifest from %s. Error: %s' % (
            webapp.manifest_url, e)
        failed_fetches[id] = failed_fetches.get(id, 0) + 1
        if failed_fetches[id] == 3:
            # This is our 3rd attempt, let's send the developer(s) an email to
            # notify him of the failures.
            notify_developers_of_failure(webapp, u'Validation errors:\n' + msg)
        elif failed_fetches[id] >= 4:
            # This is our 4th attempt, we should already have notified the
            # developer(s). Let's put the app in the re-review queue.
            _log(webapp, msg, rereview=True, exc_info=True)
            if webapp.status in mkt.WEBAPPS_APPROVED_STATUSES:
                RereviewQueue.flag(webapp, mkt.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Пример #8
0
def _flag_rereview_adult(app, ratings_body, rating):
    """Flag app for rereview if it receives an Adult content rating."""
    old_rating = app.content_ratings.filter(ratings_body=ratings_body.id)
    if not old_rating.exists():
        return

    if rating.adult and not old_rating[0].get_rating().adult:
        RereviewQueue.flag(app, amo.LOG.CONTENT_RATING_TO_ADULT, message=_("Content rating changed to Adult."))
Пример #9
0
def mark_for_rereview(addon, added_devices, removed_devices):
    msg = _(u"Device(s) changed: {0}").format(
        ", ".join(
            [_(u"Added {0}").format(unicode(mkt.DEVICE_TYPES[d].name)) for d in added_devices]
            + [_(u"Removed {0}").format(unicode(mkt.DEVICE_TYPES[d].name)) for d in removed_devices]
        )
    )
    RereviewQueue.flag(addon, mkt.LOG.REREVIEW_DEVICES_ADDED, msg)
Пример #10
0
def _flag_rereview_adult(app, ratings_body, rating):
    """Flag app for rereview if it receives an Adult content rating."""
    old_rating = app.content_ratings.filter(ratings_body=ratings_body.id)
    if not old_rating.exists():
        return

    if rating.adult and not old_rating[0].get_rating().adult:
        RereviewQueue.flag(
            app, mkt.LOG.CONTENT_RATING_TO_ADULT,
            message=_('Content rating changed to Adult.'))
Пример #11
0
    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)
Пример #12
0
    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)
Пример #13
0
    def save(self):
        if 'price' in self.cleaned_data:
            premium = self.addon.premium
            if not premium:
                premium = AddonPremium()
                premium.addon = self.addon
            premium.price = self.cleaned_data['price']
            premium.save()

        upsell = self.addon.upsold
        if self.cleaned_data['free']:

            # Check if this app was already a premium version for another app.
            if upsell and upsell.free != self.cleaned_data['free']:
                upsell.delete()

            if not upsell:
                upsell = AddonUpsell(premium=self.addon)
            upsell.free = self.cleaned_data['free']
            upsell.save()
        elif not self.cleaned_data['free'] and upsell:
            upsell.delete()

        # Check for free -> paid for already public apps.
        premium_type = self.cleaned_data['premium_type']
        if (self.addon.premium_type == amo.ADDON_FREE and
            premium_type in amo.ADDON_PREMIUMS and
            self.addon.status == amo.STATUS_PUBLIC):
            # Free -> paid for public apps trigger re-review.
            log.info(u'[Webapp:%s] (Re-review) Public app, free -> paid.' % (
                self.addon))
            RereviewQueue.flag(self.addon, amo.LOG.REREVIEW_FREE_TO_PAID)

        self.addon.premium_type = premium_type

        if self.addon.premium and waffle.switch_is_active('currencies'):
            currencies = self.cleaned_data['currencies']
            self.addon.premium.update(currencies=currencies)

        self.addon.save()

        # If they checked later in the wizard and then decided they want
        # to keep it free, push to pending.
        if not self.addon.needs_paypal() and self.addon.is_incomplete():
            self.addon.mark_done()
Пример #14
0
def _update_manifest(id):
    webapp = Webapp.objects.get(pk=id)
    file_ = webapp.get_latest_file()

    _log(webapp, u'Fetching webapp manifest')
    if not file_:
        _log(webapp, u'Ignoring, no existing file')
        return

    # Fetch manifest, catching and logging any exception.
    try:
        content = _fetch_manifest(webapp.manifest_url)
    except Exception, e:
        msg = u'Failed to get manifest from %s. Error: %s' % (
            webapp.manifest_url, e.message)
        _log(webapp, msg, rereview=True, exc_info=True)
        RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE, msg)
        return
Пример #15
0
def _update_manifest(id):
    webapp = Webapp.objects.get(pk=id)
    file_ = webapp.get_latest_file()

    _log(webapp, u'Fetching webapp manifest')
    if not file_:
        _log(webapp, u'Ignoring, no existing file')
        return

    # Fetch manifest, catching and logging any exception.
    try:
        content = _fetch_manifest(webapp.manifest_url)
    except Exception, e:
        msg = u'Failed to get manifest from %s. Error: %s' % (
            webapp.manifest_url, e.message)
        _log(webapp, msg, rereview=True, exc_info=True)
        RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE, msg)
        return
Пример #16
0
    def save(self, addon, commit=False):
        # We ignore `commit`, since we need it to be `False` so we can save
        # the ManyToMany fields on our own.
        addonform = super(AppFormBasic, self).save(commit=False)
        addonform.save()

        if 'manifest_url' in self.changed_data:
            before_url = self.old_manifest_url
            after_url = self.cleaned_data['manifest_url']

            # If a non-admin edited the manifest URL, add to Re-review Queue.
            if not acl.action_allowed(self.request, 'Admin', '%'):
                log.info(u'[Webapp:%s] (Re-review) Manifest URL changed '
                         u'from %s to %s'
                         % (self.instance, before_url, after_url))

                msg = (_(u'Manifest URL changed from {before_url} to '
                         u'{after_url}')
                       .format(before_url=before_url, after_url=after_url))

                RereviewQueue.flag(self.instance,
                                   mkt.LOG.REREVIEW_MANIFEST_URL_CHANGE, msg)

            # Refetch the new manifest.
            log.info('Manifest %s refreshed for %s'
                     % (addon.manifest_url, addon))
            update_manifests.delay([self.instance.id])

        tags_new = self.cleaned_data['tags']
        tags_old = [slugify(t, spaces=True) for t in self.get_tags(addon)]

        add_tags = set(tags_new) - set(tags_old)
        del_tags = set(tags_old) - set(tags_new)

        # Add new tags.
        for t in add_tags:
            Tag(tag_text=t).save_tag(addon)

        # Remove old tags.
        for t in del_tags:
            Tag(tag_text=t).remove_tag(addon)

        return addonform
Пример #17
0
    def save(self):
        if self.cleaned_data.get('accounts'):
            try:
                log.info('[1@%s] Attempting to delete app payment account'
                         % self.webapp.pk)
                WebappPaymentAccount.objects.get(
                    webapp=self.webapp,
                    payment_account__provider=self.provider.provider
                ).delete()
            except WebappPaymentAccount.DoesNotExist:
                log.info('[1@%s] Deleting failed, this is usually fine'
                         % self.webapp.pk)

            log.info('[1@%s] Creating new app payment account' %
                     self.webapp.pk)

            account = self.cleaned_data['accounts']

            uri = self.provider.product_create(account, self.webapp)
            WebappPaymentAccount.objects.create(
                webapp=self.webapp, account_uri=account.uri,
                payment_account=account, product_uri=uri)

            # If the app is marked as paid and the information is complete
            # and the app is currently marked as incomplete, put it into the
            # re-review queue.
            if (self.webapp.status == mkt.STATUS_NULL and
                    self.webapp.highest_status
                    in mkt.WEBAPPS_APPROVED_STATUSES):
                # FIXME: This might cause noise in the future if bank accounts
                # get manually closed by Bango and we mark apps as STATUS_NULL
                # until a new account is selected. That will trigger a
                # re-review.

                log.info(u'[Webapp:%s] (Re-review) Public app, premium type '
                         u'upgraded.' % self.webapp)
                RereviewQueue.flag(
                    self.webapp, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            if (self.webapp.has_incomplete_status() and
                    self.webapp.is_fully_complete()):
                _restore_app_status(self.webapp)
Пример #18
0
    def save(self):
        if self.cleaned_data.get('accounts'):
            try:
                log.info('[1@%s] Attempting to delete app payment account'
                         % self.addon.pk)
                AddonPaymentAccount.objects.get(
                    addon=self.addon,
                    payment_account__provider=self.provider.provider
                ).delete()
            except AddonPaymentAccount.DoesNotExist:
                log.info('[1@%s] Deleting failed, this is usually fine'
                         % self.addon.pk)

            log.info('[1@%s] Creating new app payment account' % self.addon.pk)

            account = self.cleaned_data['accounts']

            uri = self.provider.product_create(account, self.addon)
            AddonPaymentAccount.objects.create(
                addon=self.addon, account_uri=account.uri,
                payment_account=account, product_uri=uri)

            # If the app is marked as paid and the information is complete
            # and the app is currently marked as incomplete, put it into the
            # re-review queue.
            if (self.addon.status == mkt.STATUS_NULL and
                    self.addon.highest_status
                    in mkt.WEBAPPS_APPROVED_STATUSES):
                # FIXME: This might cause noise in the future if bank accounts
                # get manually closed by Bango and we mark apps as STATUS_NULL
                # until a new account is selected. That will trigger a
                # re-review.

                log.info(u'[Webapp:%s] (Re-review) Public app, premium type '
                         u'upgraded.' % self.addon)
                RereviewQueue.flag(
                    self.addon, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            if (self.addon.has_incomplete_status() and
                    self.addon.is_fully_complete()):
                _restore_app_status(self.addon)
Пример #19
0
 def test_signals(self, mock):
     RereviewQueue.flag(self.app, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)
     assert mock.called
     mock.reset()
     RereviewQueue.objects.filter(addon=self.app).delete()
     assert mock.called
Пример #20
0
    upload = FileUpload.objects.get(pk=upload.pk)
    if upload.validation:
        v8n = json.loads(upload.validation)
        if v8n['errors']:
            v8n_url = absolutify(reverse(
                'mkt.developers.upload_detail', args=[upload.uuid]))
            msg = u'Validation errors:\n'
            for m in v8n['messages']:
                if m['type'] == u'error':
                    msg += u'* %s\n' % m['message']
            msg += u'\nValidation Result:\n%s' % v8n_url
            _log(webapp, msg, rereview=True)
            if webapp.status in mkt.WEBAPPS_APPROVED_STATUSES:
                notify_developers_of_failure(webapp, msg, has_link=True)
                RereviewQueue.flag(webapp, mkt.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            return
    else:
        _log(webapp,
             u'Validation for upload UUID %s has no result' % upload.uuid)

    # Get the old manifest before we overwrite it.
    new = json.loads(content)
    old = webapp.get_manifest_json(file_)

    # New manifest is different and validates, update version/file.
    try:
        webapp.manifest_updated(content, upload)
    except:
        _log(webapp, u'Failed to create version', exc_info=True)
Пример #21
0
    upload = FileUpload.objects.get(pk=upload.pk)
    if upload.validation:
        v8n = json.loads(upload.validation)
        if v8n['errors']:
            v8n_url = absolutify(
                reverse('mkt.developers.upload_detail', args=[upload.uuid]))
            msg = u'Validation errors:\n'
            for m in v8n['messages']:
                if m['type'] == u'error':
                    msg += u'* %s\n' % m['message']
            msg += u'\nValidation Result:\n%s' % v8n_url
            _log(webapp, msg, rereview=True)
            if webapp.status in mkt.WEBAPPS_APPROVED_STATUSES:
                notify_developers_of_failure(webapp, msg, has_link=True)
                RereviewQueue.flag(webapp, mkt.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            return
    else:
        _log(webapp,
             u'Validation for upload UUID %s has no result' % upload.uuid)

    # Get the old manifest before we overwrite it.
    new = json.loads(content)
    old = webapp.get_manifest_json(file_)

    # New manifest is different and validates, update version/file.
    try:
        webapp.manifest_updated(content, upload)
    except:
        _log(webapp, u'Failed to create version', exc_info=True)
Пример #22
0
 def test_signals(self, mock):
     RereviewQueue.flag(self.app, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)
     assert mock.called
     mock.reset()
     RereviewQueue.objects.filter(addon=self.app).delete()
     assert mock.called
Пример #23
0
 def test_flag_creates_notes(self):
     RereviewQueue.flag(self.app, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)
     eq_(self.app.threads.all()[0].notes.all()[0].note_type,
         comm.REREVIEW_PREMIUM_TYPE_UPGRADE)
Пример #24
0
 def test_notify_failure_with_rereview(self):
     RereviewQueue.flag(self.addon, amo.LOG.REREVIEW_MANIFEST_CHANGE,
                        'This app is flagged!')
     notify_developers_of_failure(self.addon, 'blah')
     eq_(len(mail.outbox), 0)
Пример #25
0
 def test_notify_failure_with_rereview(self):
     RereviewQueue.flag(self.addon, mkt.LOG.REREVIEW_MANIFEST_CHANGE,
                        'This app is flagged!')
     notify_developers_of_failure(self.addon, 'blah')
     eq_(len(mail.outbox), 0)
Пример #26
0
def mark_for_rereview_features_change(addon, added_features, removed_features):
    # L10n: {0} is the list of requirements changes.
    msg = _(u'Requirements changed: {0}').format(
        ', '.join([_(u'Added {0}').format(f) for f in added_features] +
                  [_(u'Removed {0}').format(f) for f in removed_features]))
    RereviewQueue.flag(addon, amo.LOG.REREVIEW_FEATURES_CHANGED, msg)
Пример #27
0
 def test_flag_creates_notes(self):
     RereviewQueue.flag(self.app, mkt.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)
     eq_(self.app.threads.all()[0].notes.all()[0].note_type,
         comm.REREVIEW_PREMIUM_TYPE_UPGRADE)