Ejemplo n.º 1
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:
            _log(webapp, msg, rereview=True, exc_info=True)
            if webapp.status in amo.WEBAPPS_APPROVED_STATUSES:
                RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Ejemplo n.º 2
0
    def save(self):
        if self.cleaned_data.get('accounts'):
            try:
                log.info('[1@%s] Deleting app payment account' % self.addon.pk)
                AddonPaymentAccount.objects.get(addon=self.addon).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            log.info('[1@%s] Creating new app payment account' % self.addon.pk)
            AddonPaymentAccount.create(
                provider='bango',
                addon=self.addon,
                payment_account=self.cleaned_data['accounts'])

            # 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 == amo.STATUS_NULL
                    and self.addon.highest_status
                    in amo.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,
                                   amo.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            _restore_app(self.addon)
Ejemplo n.º 3
0
    def save(self):
        if self.cleaned_data.get("accounts"):
            try:
                log.info("[1@%s] Deleting app payment account" % self.addon.pk)
                AddonPaymentAccount.objects.get(addon=self.addon).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            log.info("[1@%s] Creating new app payment account" % self.addon.pk)
            AddonPaymentAccount.create(
                provider="bango", addon=self.addon, payment_account=self.cleaned_data["accounts"]
            )

            # 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 == amo.STATUS_NULL and self.addon.highest_status == amo.STATUS_PUBLIC:
                # 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, amo.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            _restore_app(self.addon)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def mark_for_rereview_form_factors(addon, added, removed):
    msg = _(u'Form Factor(s) changed: {0}').format(', '.join(
        [_(u'Added {0}').format(unicode(mkt.FORM_FACTOR_CHOICES[f].name))
         for f in added] +
        [_(u'Removed {0}').format(unicode(mkt.FORM_FACTOR_CHOICES[f].name))
         for f in removed]))
    RereviewQueue.flag(addon, amo.LOG.REREVIEW_FORM_FACTORS_ADDED, msg)
Ejemplo n.º 6
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:
            _log(webapp, msg, rereview=True, exc_info=True)
            if webapp.status in amo.WEBAPPS_APPROVED_STATUSES:
                RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Ejemplo n.º 7
0
def mark_for_rereview(addon, added_platforms, removed_platforms):
    msg = _(u'Platform(s) changed: {0}').format(', '.join(
        [_(u'Added {0}').format(unicode(mkt.PLATFORM_TYPES[p].name))
         for p in added_platforms] +
        [_(u'Removed {0}').format(unicode(mkt.PLATFORM_TYPES[p].name))
         for p in removed_platforms]))
    RereviewQueue.flag(addon, amo.LOG.REREVIEW_PLATFORMS_ADDED, msg)
Ejemplo n.º 8
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 amo.WEBAPPS_APPROVED_STATUSES:
                RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE,
                                   msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Ejemplo n.º 9
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)
Ejemplo n.º 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, amo.LOG.CONTENT_RATING_TO_ADULT,
            message=_('Content rating changed to Adult.'))
Ejemplo n.º 11
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()
Ejemplo n.º 12
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()
Ejemplo n.º 13
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
Ejemplo n.º 14
0
    def save(self, addon):
        new_types = self.cleaned_data['device_types']
        old_types = [x.id for x in addon.device_types]

        added_devices = set(new_types) - set(old_types)
        removed_devices = set(old_types) - set(new_types)

        for d in added_devices:
            AddonDeviceType(addon=addon, device_type=d).save()
        for d in removed_devices:
            AddonDeviceType.objects.filter(
                addon=addon, device_type=d).delete()

        # Send app to re-review queue if public and new devices are added.
        if added_devices and self.addon.status == amo.STATUS_PUBLIC:
            msg = _(u'Device(s) changed: %s' % (
                ', '.join([u'Added %s' % unicode(amo.DEVICE_TYPES[d].name)
                           for d in added_devices] +
                          [u'Removed %s' % unicode(amo.DEVICE_TYPES[d].name)
                           for d in removed_devices])))
            RereviewQueue.flag(self.addon, amo.LOG.REREVIEW_DEVICES_ADDED, msg)
Ejemplo n.º 15
0
    def save(self):
        if self.cleaned_data.get('accounts'):
            try:
                log.info('[1@%s] Deleting app payment account' % self.addon.pk)
                AddonPaymentAccount.objects.get(
                    addon=self.addon,
                    payment_account__provider=self.provider.provider
                ).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            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 == amo.STATUS_NULL and
                self.addon.highest_status in amo.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, amo.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            if (self.addon.has_incomplete_status() and
                    self.addon.is_fully_complete()):
                _restore_app_status(self.addon)
Ejemplo n.º 16
0
def _update_manifest(id, check_hash, failed_fetches):
    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)
        failed_fetches[id] = failed_fetches.get(id, 0) + 1
        if failed_fetches[id] >= 3:
            _log(webapp, msg, rereview=True, exc_info=True)
            RereviewQueue.flag(webapp, amo.LOG.REREVIEW_MANIFEST_CHANGE, msg)
            del failed_fetches[id]
        else:
            _log(webapp, msg, rereview=False, exc_info=True)
        return
Ejemplo n.º 17
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 amo.WEBAPPS_APPROVED_STATUSES:
                notify_developers_of_failure(webapp, msg, has_link=True)
                RereviewQueue.flag(webapp, amo.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)
Ejemplo n.º 18
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)
Ejemplo n.º 19
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)
Ejemplo n.º 20
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)
Ejemplo n.º 21
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)