Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add checkmark/pitch depending on pre-approval status (bug 740924)

  • Loading branch information...
commit 7facdd273c10782472a28f75877d8643e49a49c0 1 parent 6c7e7c2
@cvan cvan authored
View
49 media/css/mkt/detail.less
@@ -3,6 +3,54 @@
@text-gray: #424f5a;
@link: #2d87ca;
+.checkmark {
+ display: block;
+ color: @black;
+ font-weight: bold;
+ font-size: 12px;
+ line-height: 20px;
+ &:before {
+ .border-radius(10px);
+ background-color: @green;
+ color: @white;
+ content: "\2714"; /* checkmark */
+ display: inline-block;
+ font-weight: normal;
+ height: 20px;
+ margin-right: 5px;
+ position: relative;
+ text-align: center;
+ width: 20px;
+ }
+}
+
+.actions {
+ .button {
+ position: relative;
+ z-index: 1;
+ }
+ .approval {
+ .border-radius(0 0 5px 5px);
+ background: fadeOut(@green, 90%);
+ display: block;
+ margin-top: -5px;
+ padding: 15px 5px 10px;
+ position: relative;
+ z-index: 0;
+ }
+ .approval-pitch {
+ display: block;
+ color: @dark-gray;
+ font-size: 12px;
+ font-weight: bold;
+ padding-top: 8px;
+ text-align: center;
+ &:hover {
+ color: @medium-gray;
+ }
+ }
+}
+
.icon {
background: @white;
.border-radius(2px);
@@ -257,7 +305,6 @@
}
.listing .device-list {
- padding-top: 3px;
text-align: center;
h4, ul {
display: block;
View
8 mkt/detail/templates/detail/app.html
@@ -61,6 +61,14 @@ <h3 class="hidden">{{ _('Categories') }}</h3>
<div class="actions">
{% if product.is_public() %}
{{ market_button(product) }}
+ {% if product.can_purchase() %}
+ {% if request.amo_user and request.amo_user.get_preapproval().paypal_key %}
+ <span class="approval checkmark">{{ _('PayPal pre-approval') }}</span>
+ {% else %}
+ <a class="approval-pitch" href="{{ url('account.payment') }}">
+ {{ _('Set up purchasing') }}</a>
+ {% endif %}
+ {% endif %}
{% endif %}
{% if is_dev %}
<p><a href="{{ product.get_dev_url() }}" class="button developer manage">
View
35 mkt/detail/tests/test_views.py
@@ -13,7 +13,9 @@
from amo.helpers import external_url
import amo.tests
from addons.models import AddonCategory, AddonUpsell, AddonUser, Category
+from market.models import PreApprovalUser
from users.models import UserProfile
+
from mkt.webapps.models import Webapp
@@ -31,6 +33,9 @@ def setUp(self):
def get_webapp(self):
return Webapp.objects.get(id=337141)
+ def get_user(self):
+ return UserProfile.objects.get(email='regular@mozilla.com')
+
def get_pq(self):
r = self.client.get(self.url)
eq_(r.status_code, 200)
@@ -153,6 +158,36 @@ def test_has_homepage(self):
eq_(url.find('a').text(), self.webapp.homepage)
eq_(url.find('a').attr('href'), external_url(self.webapp.homepage))
+ def test_free_no_preapproval(self):
+ eq_(self.get_pq()('.approval-pitch, .approval.checkmark').length, 0)
+
+ def test_free_preapproval_enabled(self):
+ PreApprovalUser.objects.create(user=self.get_user(), paypal_key='xyz')
+ eq_(self.get_pq()('.approval-pitch, .approval.checkmark').length, 0)
+
+ def test_paid_no_preapproval_anonymous(self):
+ self.make_premium(self.webapp)
+ doc = self.get_pq()
+ eq_(doc('.approval-pitch').length, 1)
+ eq_(doc('.approval.checkmark').length, 0)
+
+ def test_paid_no_preapproval_authenticated(self):
+ assert self.client.login(username='regular@mozilla.com',
+ password='password')
+ self.make_premium(self.webapp)
+ doc = self.get_pq()
+ eq_(doc('.approval-pitch').length, 1)
+ eq_(doc('.approval.checkmark').length, 0)
+
+ def test_paid_preapproval_enabled(self):
+ self.make_premium(self.webapp)
+ user = self.get_user()
+ assert self.client.login(username=user.email, password='password')
+ PreApprovalUser.objects.create(user=user, paypal_key='xyz')
+ doc = self.get_pq()
+ eq_(doc('.approval-pitch').length, 0)
+ eq_(doc('.approval.checkmark').length, 1)
+
class TestDetailPagePermissions(DetailBase):
View
5 mkt/webapps/models.py
@@ -22,7 +22,7 @@
from addons import query
from addons.models import Addon, update_name_table, update_search_index
from files.models import FileUpload, Platform
-from lib.crypto.receipt import sign, cef
+from lib.crypto.receipt import sign
from versions.models import Version
import jwt
@@ -195,6 +195,9 @@ def authors_other_addons(self, app=None):
.filter(addonuser__listed=True,
authors__in=self.listed_authors))
+ def can_purchase(self):
+ return self.is_premium() and self.premium and self.is_public()
+
# Pull all translated_fields from Addon over to Webapp.
Webapp._meta.translated_fields = Addon._meta.translated_fields
Please sign in to comment.
Something went wrong with that request. Please try again.