Skip to content
Browse files

let reviewers/owners install pending apps (bug 746910)

  • Loading branch information...
1 parent bce79b0 commit d216fbe7f2627ed98136c1c24b63f2e3d57f2ea7 @cvan cvan committed Apr 19, 2012
View
12 media/css/mkt/buttons.less
@@ -6,6 +6,10 @@
@btn-r-dark: darken(spin(@btn-r, 3), 8%);
@btn-r-lite: saturate(spin(@btn-r, 4), 60%);
+@btn-g: lighten(spin(@btn-b, -115), 4%);
+@btn-g-dark: darken(spin(@btn-g, 3), 8%);
+@btn-g-lite: saturate(spin(@btn-g, 4), 60%);
+
.button, button {
.gradient-two-color(@btn-b, @btn-b-dark);
.border-radius(4px);
@@ -20,6 +24,14 @@
text-align: center;
text-decoration: none;
text-shadow: 0 1px 0 rgba(0,0,0,.25);
+ &.good {
+ .gradient-two-color(@btn-g, @btn-g-dark);
+ &:hover {
+ .box-shadow(0 2px 0 0 rgba(0,0,0,.1),
+ inset 0 -2px 0 0 rgba(0,0,0,.2),
+ inset 0 12px 24px 2px @btn-g-lite);
+ }
+ }
&.delete, &.manage {
.gradient-two-color(@btn-r, @btn-r-dark);
&:hover {
View
16 media/css/mkt/detail.less
@@ -29,15 +29,29 @@
position: relative;
z-index: 1;
}
+ .faked-purchase,
.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;
}
+ .faked-purchase {
+ .border-radius(0 0 5px 5px);
+ background: fadeOut(@red, 90%);
+ font-size: 12px;
+ text-align: center;
+ b {
+ color: @maroon;
+ display: block;
+ text-transform: uppercase;
+ }
+ }
+ .approval {
+ background: fadeOut(@green, 90%);
+ }
.approval-pitch {
display: block;
color: @dark-gray;
View
1 media/css/mkt/lib.less
@@ -30,6 +30,7 @@
@faded-blue: fadeOut(@border-blue, 90%);
@orange: #d60;
@red: #c00000;
+@maroon: #800;
@green: #090;
@black: #000;
@dark-gray: #333;
View
3 media/js/mkt/fragments.js
@@ -14,7 +14,8 @@
href.substr(0,1) === '#' ||
href.indexOf('/developers/') !== -1 ||
href.indexOf('/statistics/') !== -1 ||
- href.indexOf('?modified=') !== -1) {
+ href.indexOf('?modified=') !== -1 ||
+ this.getAttribute('target') === '_blank') {
return;
}
e.preventDefault();
View
9 mkt/detail/templates/detail/app.html
@@ -69,11 +69,18 @@ <h3 class="hidden">{{ _('Categories') }}</h3>
{{ _('Set up purchasing') }}</a>
{% endif %}
{% endif %}
+ {% elif is_dev or is_reviewer %}
+ {{ market_button(product) }}
{% endif %}
{% if is_dev %}
- <p><a href="{{ product.get_dev_url() }}" class="button developer manage">
+ <p><a href="{{ product.get_dev_url() }}" class="button manage">
{{ _('Manage') }}</a></p>
{% endif %}
+ {% if is_reviewer and product.is_pending() %}
+ <p><a href="{{ url('reviewers.app_review', product.app_slug) }}"
+ class="button good" target="_blank">
+ {{ _('Approve / Reject') }}</a></p>
+ {% endif %}
</div>
</section>
View
5 mkt/detail/templates/detail/protected_app.html
@@ -9,6 +9,11 @@
{% set is_dev = request.check_ownership(product, require_owner=False,
ignore_disabled=True) %}
+{# Reviewers should be able to see pending apps. #}
+{% if not is_admin and is_reviewer and product.is_pending() %}
+ {% set is_admin = True %}
+{% endif %}
+
{% macro notification(product, amo, is_dev) %}
{% if not product.is_public() %}
<section id="product-status" class="full notification-box">
View
77 mkt/detail/tests/test_views.py
@@ -57,6 +57,81 @@ def test_categories(self):
eq_(links.attr('href'), cat.get_url_path())
eq_(links.text(), cat.name)
+ def test_free_install_button_for_anon(self):
+ doc = self.get_pq()
+ eq_(doc('.product').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+
+ def test_free_install_button_for_owner(self):
+ assert self.client.login(username='steamcube@mozilla.com',
+ password='password')
+ doc = self.get_pq()
+ eq_(doc('.product').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+ eq_(doc('.manage').length, 1)
+
+ def test_free_install_button_for_dev(self):
+ user = UserProfile.objects.get(username='regularuser')
+ assert self.client.login(username=user.email, password='password')
+ AddonUser.objects.create(addon=self.webapp, user=user)
+ doc = self.get_pq()
+ eq_(doc('.product').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+ eq_(doc('.manage').length, 1)
+
+ def test_free_install_button_for_reviewer(self):
+ assert self.client.login(username='editor@mozilla.com',
+ password='password')
+ doc = self.get_pq()
+ eq_(doc('.product').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+ eq_(doc('.manage').length, 0)
+
+ def test_paid_install_button_for_anon(self):
+ # This purchase should not be faked.
+ self.make_premium(self.webapp)
+ doc = self.get_pq()
+ eq_(doc('.product.premium').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+
+ def test_paid_install_button_for_owner(self):
+ self.make_premium(self.webapp)
+ assert self.client.login(username='steamcube@mozilla.com',
+ password='password')
+ doc = self.get_pq()
+ eq_(doc('.product.install.premium').length, 1)
+ eq_(doc('.faked-purchase').length, 1)
+ eq_(doc('.manage').length, 1)
+
+ def test_paid_install_button_for_dev(self):
+ self.make_premium(self.webapp)
+ user = UserProfile.objects.get(username='regularuser')
+ assert self.client.login(username=user.email, password='password')
+ AddonUser.objects.create(addon=self.webapp, user=user)
+ doc = self.get_pq()
+ eq_(doc('.product.install.premium').length, 1)
+ eq_(doc('.faked-purchase').length, 1)
+ eq_(doc('.manage').length, 1)
+
+ def test_paid_public_install_button_for_reviewer(self):
+ self.make_premium(self.webapp)
+ assert self.client.login(username='editor@mozilla.com',
+ password='password')
+ doc = self.get_pq()
+ eq_(doc('.product.premium').length, 1)
+ eq_(doc('.faked-purchase').length, 0)
+ eq_(doc('.manage').length, 0)
+
+ def test_paid_pending_install_button_for_reviewer(self):
+ self.webapp.update(status=amo.STATUS_PENDING)
+ self.make_premium(self.webapp)
+ assert self.client.login(username='editor@mozilla.com',
+ password='password')
+ doc = self.get_pq()
+ eq_(doc('.product.install.premium').length, 1)
+ eq_(doc('.faked-purchase').length, 1)
+ eq_(doc('.manage').length, 0)
+
def test_manage_button_for_owner(self):
assert self.client.login(username='steamcube@mozilla.com',
password='password')
@@ -85,7 +160,7 @@ def test_upsell(self):
eq_(upsell.length, 1)
eq_(upsell.find('.upsell').text(), unicode(premie.name))
eq_(upsell.find('.icon').attr('src'), premie.get_icon_url(16))
- eq_(upsell.find('.install').attr('data-manifesturl'),
+ eq_(upsell.find('.product').attr('data-manifesturl'),
premie.manifest_url)
eq_(upsell.find('.prose').text(), 'XXX')
View
2 mkt/reviewers/templates/reviewers/review.html
@@ -15,7 +15,7 @@
<header class="c">
<ul id="actions">
<li><a href="{{ product.get_url_path() }}" class="button">
- {{ _('View Listing') }}</a></li>
+ {{ _('View Listing / Install') }}</a></li>
{% if is_admin %}
<li><a href="{{ product.get_dev_url() }}" class="button manage">
{{ _('Edit') }}</a></li>
View
3 mkt/site/context_processors.py
@@ -23,6 +23,7 @@ def global_settings(request):
if request.user.is_authenticated() and hasattr(request, 'amo_user'):
amo_user = request.amo_user
account_links = []
+ context['is_reviewer'] = acl.check_reviewer(request)
if waffle.switch_is_active('unleash-consumer'):
account_links = [
{'text': _('My Purchases'),
@@ -38,7 +39,7 @@ def global_settings(request):
if '/developers/' not in request.path:
tools_links.append({'text': _('Developer Hub'),
'href': reverse('mkt.developers.index')})
- if '/reviewers/' not in request.path and acl.check_reviewer(request):
+ if '/reviewers/' not in request.path and context['is_reviewer']:
tools_links.append({'text': _('Reviewer Tools'),
'href': reverse('reviewers.home')})
if acl.action_allowed(request, 'Localizers', '%'):
View
10 mkt/site/helpers.py
@@ -28,22 +28,28 @@ def no_results():
def market_button(context, product):
request = context['request']
if product.is_webapp():
+ faked_purchase = False
purchased = (request.amo_user and
product.pk in request.amo_user.purchase_ids())
+ is_dev = request.check_ownership(product, require_owner=False,
+ ignore_disabled=True)
+ if (not purchased and is_dev or product.is_pending() and
+ (context['is_reviewer'] or context['is_admin'])):
+ purchased = faked_purchase = True
classes = ['button', 'product']
label = price_label(product)
product_dict = product_as_dict(request, product, purchased=purchased)
data_attrs = {
'product': json.dumps(product_dict, cls=JSONEncoder),
- 'manifestUrl': product.manifest_url,
+ 'manifestUrl': product.manifest_url
}
if product.is_premium() and product.premium:
classes.append('premium')
if not product.is_premium() or purchased:
classes.append('install')
label = _('Install')
# TODO: Show inline BroswerID login popup for non-authenticated users.
- c = dict(product=product, label=label,
+ c = dict(product=product, label=label, faked_purchase=faked_purchase,
data_attrs=data_attrs, classes=' '.join(classes))
t = env.get_template('site/helpers/webapp_button.html')
return jinja2.Markup(t.render(c))
View
7 mkt/site/templates/site/helpers/webapp_button.html
@@ -4,3 +4,10 @@
class="{{ classes }}">
{{ label }}
</a>
+{% if faked_purchase and product.is_premium() and product.premium %}
+ <p class="faked-purchase">
+ <b>Sample</b>
+ This would've cost you
+ <span class="price">{{ product.premium.get_price_locale() }}</span>
+ </p>
+{% endif %}
View
3 mkt/webapps/models.py
@@ -198,6 +198,9 @@ def authors_other_addons(self, app=None):
def can_purchase(self):
return self.is_premium() and self.premium and self.is_public()
+ def is_pending(self):
+ return self.status == amo.STATUS_PENDING
+
# Pull all translated_fields from Addon over to Webapp.
Webapp._meta.translated_fields = Addon._meta.translated_fields

0 comments on commit d216fbe

Please sign in to comment.
Something went wrong with that request. Please try again.