hide Manage Payments, etc. links and add messaging (bug 782365)
This commit is contained in:
Родитель
a2ddeb1908
Коммит
f1b8213521
|
@ -349,15 +349,21 @@ class TestCase(RedisTest, test_utils.TestCase):
|
||||||
addon.update(premium_type=amo.ADDON_PREMIUM)
|
addon.update(premium_type=amo.ADDON_PREMIUM)
|
||||||
AddonPremium.objects.create(addon=addon, price=price)
|
AddonPremium.objects.create(addon=addon, price=price)
|
||||||
|
|
||||||
def create_sample(self, **kw):
|
def create_sample(self, name=None, **kw):
|
||||||
|
if name is not None:
|
||||||
|
kw['name'] = name
|
||||||
kw.setdefault('percent', 100)
|
kw.setdefault('percent', 100)
|
||||||
Sample.objects.create(**kw)
|
Sample.objects.create(**kw)
|
||||||
|
|
||||||
def create_switch(self, **kw):
|
def create_switch(self, name=None, **kw):
|
||||||
|
if name is not None:
|
||||||
|
kw['name'] = name
|
||||||
kw.setdefault('active', True)
|
kw.setdefault('active', True)
|
||||||
Switch.objects.create(**kw)
|
Switch.objects.create(**kw)
|
||||||
|
|
||||||
def create_flag(self, **kw):
|
def create_flag(self, name=None, **kw):
|
||||||
|
if name is not None:
|
||||||
|
kw['name'] = name
|
||||||
kw.setdefault('everyone', True)
|
kw.setdefault('everyone', True)
|
||||||
Flag.objects.create(**kw)
|
Flag.objects.create(**kw)
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ textarea {
|
||||||
border: 1px solid #CCD6E3;
|
border: 1px solid #CCD6E3;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background: #E3EDFA;
|
background: #E3EDFA;
|
||||||
|
line-height: 1.3;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
form {
|
form {
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
|
@ -93,11 +94,37 @@ textarea {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p {
|
p {
|
||||||
margin: .5em 0 0;
|
margin: 0;
|
||||||
|
+ p {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b {
|
b {
|
||||||
color: #333;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.error {
|
||||||
|
b, a {
|
||||||
|
color: @maroon;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: darken(@maroon, 10%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.notice {
|
||||||
|
b, a {
|
||||||
|
color: @blue;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: darken(@blue, 10%);
|
||||||
|
}
|
||||||
|
}
|
||||||
h1 {
|
h1 {
|
||||||
color: maroon;
|
color: maroon;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
@black: #000;
|
@black: #000;
|
||||||
@white: #fff;
|
@white: #fff;
|
||||||
@red: #C63717;
|
@red: #C63717;
|
||||||
|
@maroon: #800;
|
||||||
@error-red: #C00000;
|
@error-red: #C00000;
|
||||||
@orange: #D16B00;
|
@orange: #D16B00;
|
||||||
@notice-yellow: #FAF2BD;
|
@notice-yellow: #FAF2BD;
|
||||||
|
|
|
@ -197,3 +197,13 @@ def display_url(url):
|
||||||
bytes = urllib.unquote(url)
|
bytes = urllib.unquote(url)
|
||||||
c = chardet.detect(bytes)
|
c = chardet.detect(bytes)
|
||||||
return bytes.decode(c['encoding'], 'replace')
|
return bytes.decode(c['encoding'], 'replace')
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag('developers/helpers/disabled_payments_notice.html')
|
||||||
|
@jinja2.contextfunction
|
||||||
|
def disabled_payments_notice(context):
|
||||||
|
"""
|
||||||
|
If payments are disabled, we show a friendly message urging the developer
|
||||||
|
to make his/her app free.
|
||||||
|
"""
|
||||||
|
return {'request': context.get('request'), 'addon': context.get('addon')}
|
||||||
|
|
|
@ -28,10 +28,17 @@
|
||||||
<li>
|
<li>
|
||||||
<a class="action-link" href="{{ addon.get_dev_url('owner') }}">{{ _('Manage Authors') }}</a>
|
<a class="action-link" href="{{ addon.get_dev_url('owner') }}">{{ _('Manage Authors') }}</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
{% if not waffle.switch('disabled-payments') or addon.is_premium() %}
|
||||||
<a class="action-link" href="{{ addon.get_dev_url('payments') }}">
|
<li>
|
||||||
{{ _('Manage Payments') }}</a>
|
<a class="action-link{{ ' alert' if waffle.switch('disabled-payments') and addon.is_premium() }}" href="{{ addon.get_dev_url('payments') }}">
|
||||||
</li>
|
{{ _('Manage Payments') }}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if waffle.switch('disabled-payments') %}
|
||||||
|
<li>
|
||||||
|
<a class="action-link status-link" href="{{ addon.get_dev_url('versions') }}">{{ _('Manage Status') }}</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if request.can_view_consumer %}
|
{% if request.can_view_consumer %}
|
||||||
<li>
|
<li>
|
||||||
<a class="action-link" href="{{ addon.get_url_path() }}">{{ _('View Listing') }}</a>
|
<a class="action-link" href="{{ addon.get_url_path() }}">{{ _('View Listing') }}</a>
|
||||||
|
@ -42,34 +49,36 @@
|
||||||
<a class="action-link stats-link" href="{{ addon.get_stats_url() }}">{{ _('View Statistics') }}</a>
|
<a class="action-link stats-link" href="{{ addon.get_stats_url() }}">{{ _('View Statistics') }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<li>
|
{% if not waffle.switch('disabled-payments') %}
|
||||||
<a href="#" class="more-actions">{{ _('More') }}</a>
|
<li>
|
||||||
<div class="more-actions-popup popup hidden">
|
<a href="#" class="more-actions">{{ _('More') }}</a>
|
||||||
{% set manage_urls = [
|
<div class="more-actions-popup popup hidden">
|
||||||
(addon.get_dev_url('versions'), _('Manage Status')),
|
{% set manage_urls = [
|
||||||
] %}
|
(addon.get_dev_url('versions'), _('Manage Status')),
|
||||||
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
] %}
|
||||||
check_addon_ownership(request, addon, support=True) %}
|
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
||||||
{% do manage_urls.insert(1,
|
check_addon_ownership(request, addon, support=True) %}
|
||||||
(addon.get_dev_url('refunds'), _('Manage Refunds'))
|
{% do manage_urls.insert(1,
|
||||||
) %}
|
(addon.get_dev_url('refunds'), _('Manage Refunds'))
|
||||||
{% endif %}
|
) %}
|
||||||
{% if addon.needs_paypal() %}
|
{% endif %}
|
||||||
{% do manage_urls.insert(1,
|
{% if addon.needs_paypal() %}
|
||||||
(addon.get_dev_url('paypal_setup'), _('Manage PayPal'))) %}
|
{% do manage_urls.insert(1,
|
||||||
{% endif %}
|
(addon.get_dev_url('paypal_setup'), _('Manage PayPal'))) %}
|
||||||
{% if addon.is_webapp() and addon.premium_type in amo.ADDON_INAPPS
|
{% endif %}
|
||||||
and waffle.switch('in-app-payments') %}
|
{% if addon.is_webapp() and addon.premium_type in amo.ADDON_INAPPS
|
||||||
{% do manage_urls.insert(1,
|
and waffle.switch('in-app-payments') %}
|
||||||
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
{% do manage_urls.insert(1,
|
||||||
) %}
|
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
||||||
{% endif %}
|
) %}
|
||||||
<ul>
|
{% endif %}
|
||||||
{% for url, title in manage_urls %}
|
<ul>
|
||||||
<li><a href="{{ url }}">{{ title }}</a></li>
|
{% for url, title in manage_urls %}
|
||||||
{% endfor %}
|
<li><a href="{{ url }}">{{ title }}</a></li>
|
||||||
</ul>
|
{% endfor %}
|
||||||
</div>
|
</ul>
|
||||||
</li>
|
</div>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
{% if waffle.switch('disabled-payments') %}
|
||||||
|
<div class="no-payments notification-box notice c">
|
||||||
|
<p>
|
||||||
|
{% if request.path == addon.get_dev_url('payments') %}
|
||||||
|
{% set payments_url = '#payments-premium-type' %}
|
||||||
|
{% else %}
|
||||||
|
{% set payments_url = addon.get_dev_url('payments') + '#payments-premium-type' %}
|
||||||
|
{% endif %}
|
||||||
|
{% trans %}
|
||||||
|
Sorry, <b>payments are currently disabled</b> but are coming soon.
|
||||||
|
If you would like users to be able to install your app, please,
|
||||||
|
for the time being, <a href="{{ payments_url }}">make your app free</a>.
|
||||||
|
You will be notified via email when payments are re-enabled.
|
||||||
|
Thanks for your patience.
|
||||||
|
{% endtrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
|
@ -1,24 +1,28 @@
|
||||||
{% set urls = [
|
{% set urls = [
|
||||||
(addon.get_dev_url(), _('Edit Listing')),
|
(addon.get_dev_url(), _('Edit Listing')),
|
||||||
(addon.get_dev_url('owner'), _('Manage Authors')),
|
(addon.get_dev_url('owner'), _('Manage Authors')),
|
||||||
(addon.get_dev_url('payments'), _('Manage Payments')),
|
|
||||||
] %}
|
] %}
|
||||||
{# TODO(cvan): Remove this when we fix/remove all the add-ons tests. #}
|
{# TODO(cvan): Remove this when we fix/remove all the add-ons tests. #}
|
||||||
{% if addon.is_webapp() %}
|
{% if addon.is_webapp() %}
|
||||||
{% do urls.append((addon.get_dev_url('versions'), _('Manage Status'))) %}
|
{% do urls.append((addon.get_dev_url('versions'), _('Manage Status'))) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
{% if not waffle.switch('disabled-payments') or addon.is_premium() %}
|
||||||
check_addon_ownership(request, addon, support=True) %}
|
{% do urls.append((addon.get_dev_url('payments'), _('Manage Payments'))) %}
|
||||||
{% do urls.insert(4, (addon.get_dev_url('refunds'), _('Manage Refunds'))) %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if addon.needs_paypal() %}
|
{% if not waffle.switch('disabled-payments') %}
|
||||||
{% do urls.insert(4, (addon.get_dev_url('paypal_setup'), _('Manage PayPal'))) %}
|
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
||||||
{% endif %}
|
check_addon_ownership(request, addon, support=True) %}
|
||||||
{% if addon.is_webapp() and addon.premium_type in amo.ADDON_INAPPS
|
{% do urls.insert(4, (addon.get_dev_url('refunds'), _('Manage Refunds'))) %}
|
||||||
and waffle.switch('in-app-payments') %}
|
{% endif %}
|
||||||
{% do urls.insert(4,
|
{% if addon.needs_paypal() %}
|
||||||
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
{% do urls.insert(4, (addon.get_dev_url('paypal_setup'), _('Manage PayPal'))) %}
|
||||||
) %}
|
{% endif %}
|
||||||
|
{% if addon.is_webapp() and addon.premium_type in amo.ADDON_INAPPS
|
||||||
|
and waffle.switch('in-app-payments') %}
|
||||||
|
{% do urls.insert(4,
|
||||||
|
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
||||||
|
) %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.can_view_consumer %}
|
{% if request.can_view_consumer %}
|
||||||
{% do urls.append(
|
{% do urls.append(
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
{{ disabled_payments_notice() }}
|
||||||
<section class="primary manage" role="main">
|
<section class="primary manage" role="main">
|
||||||
<div id="in-app-config" class="devhub-form island">
|
<div id="in-app-config" class="devhub-form island">
|
||||||
<form class="item in-app-config" method="post" action="{{ request.path }}">
|
<form class="item in-app-config" method="post" action="{{ request.path }}">
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
{{ disabled_payments_notice() }}
|
||||||
<section class="primary payments devhub-form" role="main">
|
<section class="primary payments devhub-form" role="main">
|
||||||
{% if addon.paypal_id %}
|
{% if addon.paypal_id %}
|
||||||
<div class="island">
|
<div class="island">
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
{#{{ l10n_menu(addon.default_locale) }}#}
|
{#{{ l10n_menu(addon.default_locale) }}#}
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
{{ disabled_payments_notice() }}
|
||||||
<section class="primary payments island devhub-form" role="main">
|
<section class="primary payments island devhub-form" role="main">
|
||||||
<form method="post" action="{{ addon.get_dev_url('payments') }}">
|
<form method="post" action="{{ addon.get_dev_url('payments') }}">
|
||||||
{{ csrf() }}
|
{{ csrf() }}
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||||
<h1>{{ title }}</h1>
|
<h1>{{ title }}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
{{ disabled_payments_notice() }}
|
||||||
<section id="refunds" class="primary payments devhub-form" role="main">
|
<section id="refunds" class="primary payments devhub-form" role="main">
|
||||||
{% if not addon.needs_paypal() %}
|
{% if not addon.needs_paypal() %}
|
||||||
<div id="enable-payments" class="error item">
|
<div id="enable-payments" class="error item">
|
||||||
|
|
|
@ -124,9 +124,6 @@ class TestAppBreadcrumbs(AppHubTest):
|
||||||
|
|
||||||
class TestAppDashboard(AppHubTest):
|
class TestAppDashboard(AppHubTest):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(TestAppDashboard, self).setUp()
|
|
||||||
|
|
||||||
def test_no_apps(self):
|
def test_no_apps(self):
|
||||||
Addon.objects.all().delete()
|
Addon.objects.all().delete()
|
||||||
r = self.client.get(self.url)
|
r = self.client.get(self.url)
|
||||||
|
@ -161,8 +158,7 @@ class TestAppDashboard(AppHubTest):
|
||||||
eq_(doc('.more-actions-popup').length, 0)
|
eq_(doc('.more-actions-popup').length, 0)
|
||||||
|
|
||||||
def test_action_links(self):
|
def test_action_links(self):
|
||||||
waffle.models.Switch.objects.get_or_create(name='app-stats',
|
self.create_switch('app-stats')
|
||||||
active=True)
|
|
||||||
app = self.get_app()
|
app = self.get_app()
|
||||||
app.update(public_stats=True)
|
app.update(public_stats=True)
|
||||||
self.make_mine()
|
self.make_mine()
|
||||||
|
@ -177,10 +173,25 @@ class TestAppDashboard(AppHubTest):
|
||||||
amo.tests.check_links([('View Statistics', app.get_stats_url())],
|
amo.tests.check_links([('View Statistics', app.get_stats_url())],
|
||||||
doc('a.stats-link'), verify=False)
|
doc('a.stats-link'), verify=False)
|
||||||
|
|
||||||
|
def test_disabled_payments_action_links(self):
|
||||||
|
self.create_switch('app-stats')
|
||||||
|
self.create_switch('disabled-payments')
|
||||||
|
app = self.get_app()
|
||||||
|
app.update(public_stats=True)
|
||||||
|
self.make_mine()
|
||||||
|
doc = pq(self.client.get(self.url).content)
|
||||||
|
expected = [
|
||||||
|
('Edit Listing', app.get_dev_url()),
|
||||||
|
('Manage Authors', app.get_dev_url('owner')),
|
||||||
|
('Manage Status', app.get_dev_url('versions')),
|
||||||
|
('View Listing', app.get_url_path()),
|
||||||
|
('View Statistics', app.get_stats_url()),
|
||||||
|
]
|
||||||
|
amo.tests.check_links(expected, doc('a.action-link'), verify=False)
|
||||||
|
|
||||||
def test_action_links_with_payments(self):
|
def test_action_links_with_payments(self):
|
||||||
waffle.models.Switch.objects.create(name='allow-refund', active=True)
|
self.create_switch('allow-refund')
|
||||||
waffle.models.Switch.objects.create(name='in-app-payments',
|
self.create_switch('in-app-payments')
|
||||||
active=True)
|
|
||||||
app = self.get_app()
|
app = self.get_app()
|
||||||
for status in [amo.ADDON_PREMIUM_INAPP, amo.ADDON_FREE_INAPP]:
|
for status in [amo.ADDON_PREMIUM_INAPP, amo.ADDON_FREE_INAPP]:
|
||||||
app.update(premium_type=status)
|
app.update(premium_type=status)
|
||||||
|
@ -192,8 +203,23 @@ class TestAppDashboard(AppHubTest):
|
||||||
('Manage PayPal', app.get_dev_url('paypal_setup')),
|
('Manage PayPal', app.get_dev_url('paypal_setup')),
|
||||||
('Manage Refunds', app.get_dev_url('refunds')),
|
('Manage Refunds', app.get_dev_url('refunds')),
|
||||||
]
|
]
|
||||||
|
eq_(doc('.status-link').length, 0)
|
||||||
amo.tests.check_links(expected, doc('.more-actions-popup a'))
|
amo.tests.check_links(expected, doc('.more-actions-popup a'))
|
||||||
|
|
||||||
|
def test_disabled_payments_action_links_with_payments(self):
|
||||||
|
self.create_switch('allow-refund')
|
||||||
|
self.create_switch('in-app-payments')
|
||||||
|
self.create_switch('disabled-payments')
|
||||||
|
app = self.get_app()
|
||||||
|
for status in [amo.ADDON_PREMIUM_INAPP, amo.ADDON_FREE_INAPP]:
|
||||||
|
app.update(premium_type=status)
|
||||||
|
self.make_mine()
|
||||||
|
doc = pq(self.client.get(self.url).content)
|
||||||
|
status_link = doc('.status-link')
|
||||||
|
eq_(status_link.length, 1)
|
||||||
|
eq_(status_link.attr('href'), app.get_dev_url('versions'))
|
||||||
|
eq_(doc('.more-actions-popup').length, 0)
|
||||||
|
|
||||||
|
|
||||||
class TestManageLinks(AppHubTest):
|
class TestManageLinks(AppHubTest):
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
{{ progress(request, addon=addon, step=step) }}
|
{{ progress(request, addon=addon, step=step) }}
|
||||||
<section id="submit-payments" class="primary">
|
<section id="submit-payments" class="primary">
|
||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
|
{{ disabled_payments_notice() }}
|
||||||
<form method="post" class="devhub-form">
|
<form method="post" class="devhub-form">
|
||||||
<div class="brform island swagger c">
|
<div class="brform island swagger c">
|
||||||
{{ csrf() }}
|
{{ csrf() }}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче