Ejemplo n.º 1
0
    def save(self):
        if 'paypal_id' in self.cleaned_data:
            self.addon.paypal_id = self.cleaned_data['paypal_id']
            self.addon.support_email = self.cleaned_data['support_email']
            self.addon.save()

        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['do_upsell'] and
            self.cleaned_data['text'] and 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.text = self.cleaned_data['text']
            upsell.free = self.cleaned_data['free']
            upsell.save()
        elif not self.cleaned_data['do_upsell'] and upsell:
            upsell.delete()
Ejemplo n.º 2
0
    def save(self):
        if 'paypal_id' in self.cleaned_data:
            self.addon.paypal_id = self.cleaned_data['paypal_id']
            self.addon.support_email = self.cleaned_data['support_email']
            self.addon.save()

        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['do_upsell'] and self.cleaned_data['text']
                and self.cleaned_data['free']):

            if not upsell:
                upsell = AddonUpsell(premium=self.addon)
            upsell.text = self.cleaned_data['text']
            upsell.free = self.cleaned_data['free']
            upsell.save()
        elif not self.cleaned_data['do_upsell'] and upsell:
            upsell.delete()
Ejemplo n.º 3
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['do_upsell'] and
            self.cleaned_data['text'] and 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.text = self.cleaned_data['text']
            upsell.free = self.cleaned_data['free']
            upsell.save()
        elif not self.cleaned_data['do_upsell'] and upsell:
            upsell.delete()

        self.addon.premium_type = self.cleaned_data['premium_type']
        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.º 4
0
    def save_upsold(self, obj, upsold):
        current_upsell = obj.upsold
        if upsold and upsold != obj.upsold.free:
            if not current_upsell:
                log.debug('[1@%s] Creating app upsell' % obj.pk)
                current_upsell = AddonUpsell(premium=obj)
            current_upsell.free = upsold
            current_upsell.save()

        elif current_upsell:
            # We're deleting the upsell.
            log.debug('[1@%s] Deleting the app upsell' % obj.pk)
            current_upsell.delete()
Ejemplo n.º 5
0
 def test_free_with_in_app_deletes_upsell(self):
     self.make_premium(self.webapp)
     new_upsell_app = Addon.objects.create(type=self.webapp.type,
         status=self.webapp.status, name='upsell-%s' % self.webapp.id,
         premium_type=amo.ADDON_FREE)
     new_upsell = AddonUpsell(premium=self.webapp)
     new_upsell.free = new_upsell_app
     new_upsell.save()
     assert self.webapp.upsold is not None
     self.client.post(
         self.url, self.get_postdata({'price': 'free',
                                      'allow_inapp': 'True',
                                      'regions': ALL_REGION_IDS}),
                                      follow=True)
     eq_(self.get_webapp().upsold, None)
     eq_(AddonPremium.objects.all().count(), 0)
Ejemplo n.º 6
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.º 7
0
    def save(self):
        current_upsell = self.addon.upsold
        new_upsell_app = self.cleaned_data.get('upsell_of')

        if new_upsell_app:
            # We're changing the upsell or creating a new one.

            if not current_upsell:
                # If the upsell is new or we just deleted the old upsell,
                # create a new upsell.
                log.debug('[1@%s] Creating app upsell' % self.addon.pk)
                current_upsell = AddonUpsell(premium=self.addon)

            # Set the upsell object to point to the app that we're upselling.
            current_upsell.free = new_upsell_app
            current_upsell.save()

        elif current_upsell:
            # We're deleting the upsell.
            log.debug('[1@%s] Deleting the app upsell' % self.addon.pk)
            current_upsell.delete()
Ejemplo n.º 8
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 upsell:
            upsell.delete()

        self.addon.update(make_public=self.cleaned_data['make_public'])