free app with in-app payments should say "Free" not "0.00" (bug 841177)
This commit is contained in:
Родитель
a503611d0f
Коммит
614935e8a8
|
@ -1090,15 +1090,6 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
return not (self.is_premium() and self.premium and
|
||||
self.premium.has_price())
|
||||
|
||||
def needs_payment(self):
|
||||
"""
|
||||
If the addon is premium and has a price greater than zero. Primarily
|
||||
of use in the payment flow to determine if we need payment. An app can
|
||||
be premium, but not require any payment.
|
||||
"""
|
||||
return (self.premium_type in amo.ADDON_PREMIUMS and
|
||||
self.premium and self.premium.get_price())
|
||||
|
||||
def needs_paypal(self):
|
||||
return (self.premium_type not in
|
||||
(amo.ADDON_FREE, amo.ADDON_OTHER_INAPP))
|
||||
|
|
|
@ -1983,14 +1983,6 @@ class TestMarketplace(amo.tests.TestCase):
|
|||
self.addon.update(premium_type=amo.ADDON_FREE_INAPP)
|
||||
assert not self.addon.is_premium()
|
||||
|
||||
def test_is_premium_payment(self):
|
||||
self.addon.update(premium_type=amo.ADDON_PREMIUM)
|
||||
price = Price.objects.create(price='0.00')
|
||||
AddonPremium.objects.create(addon=self.addon, price=price)
|
||||
assert self.addon.is_premium()
|
||||
assert not self.addon.is_free()
|
||||
assert not self.addon.needs_payment()
|
||||
|
||||
def test_is_free(self):
|
||||
assert self.addon.is_free()
|
||||
self.addon.update(premium_type=amo.ADDON_PREMIUM)
|
||||
|
@ -2013,6 +2005,11 @@ class TestMarketplace(amo.tests.TestCase):
|
|||
self.addon.premium.update(price=price)
|
||||
assert self.addon.premium.has_price()
|
||||
|
||||
price.price = '0.00'
|
||||
price.save()
|
||||
self.addon.premium.update(price=price)
|
||||
assert not self.addon.premium.has_price()
|
||||
|
||||
def test_does_not_need_paypal(self):
|
||||
self.addon.update(premium_type=amo.ADDON_FREE)
|
||||
assert not self.addon.needs_paypal()
|
||||
|
|
|
@ -210,7 +210,7 @@ class AddonPremium(amo.models.ModelBase):
|
|||
return u'Premium %s: %s' % (self.addon, self.price)
|
||||
|
||||
def has_price(self):
|
||||
return self.price is not None
|
||||
return self.price is not None and self.price.price != '0.00'
|
||||
|
||||
def get_price(self):
|
||||
return self.price.get_price()
|
||||
|
|
|
@ -84,7 +84,7 @@ def market_button(context, product, receipt_type=None, classes=None):
|
|||
installed = installed_set.filter(addon=product).exists()
|
||||
|
||||
# Handle premium apps.
|
||||
if product.is_premium() and product.premium:
|
||||
if product.has_price():
|
||||
# User has purchased app.
|
||||
purchased = (request.amo_user and
|
||||
product.pk in request.amo_user.purchase_ids())
|
||||
|
@ -152,7 +152,7 @@ def product_as_dict(request, product, purchased=None, receipt_type=None,
|
|||
previews.append(preview)
|
||||
ret.update({'previews': previews})
|
||||
|
||||
if product.needs_payment():
|
||||
if product.has_price():
|
||||
ret.update({
|
||||
'price': product.premium.get_price() or '0',
|
||||
'priceLocale': product.premium.get_price_locale(),
|
||||
|
|
|
@ -449,10 +449,15 @@ class Webapp(Addon):
|
|||
return visible
|
||||
|
||||
def has_price(self):
|
||||
return bool(self.is_premium() and self.premium and self.premium.price)
|
||||
"""
|
||||
If the app is premium and has a price greater than zero. Primarily
|
||||
of use in the payment flow to determine if we need payment. An app can
|
||||
be premium, but not require any payment.
|
||||
"""
|
||||
return self.is_premium() and self.premium and self.premium.has_price()
|
||||
|
||||
def get_price(self):
|
||||
if self.is_premium() and self.premium:
|
||||
if self.has_price():
|
||||
return self.premium.get_price_locale()
|
||||
return _(u'Free')
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче