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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
Flag.objects.create(**kw)
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ textarea {
|
|||
border: 1px solid #CCD6E3;
|
||||
padding: 15px;
|
||||
background: #E3EDFA;
|
||||
line-height: 1.3;
|
||||
margin-bottom: 1em;
|
||||
form {
|
||||
line-height: 28px;
|
||||
|
@ -93,11 +94,37 @@ textarea {
|
|||
}
|
||||
}
|
||||
p {
|
||||
margin: .5em 0 0;
|
||||
margin: 0;
|
||||
+ p {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
b {
|
||||
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 {
|
||||
color: maroon;
|
||||
font-size: 14px;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
@black: #000;
|
||||
@white: #fff;
|
||||
@red: #C63717;
|
||||
@maroon: #800;
|
||||
@error-red: #C00000;
|
||||
@orange: #D16B00;
|
||||
@notice-yellow: #FAF2BD;
|
||||
|
|
|
@ -197,3 +197,13 @@ def display_url(url):
|
|||
bytes = urllib.unquote(url)
|
||||
c = chardet.detect(bytes)
|
||||
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>
|
||||
<a class="action-link" href="{{ addon.get_dev_url('owner') }}">{{ _('Manage Authors') }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="action-link" href="{{ addon.get_dev_url('payments') }}">
|
||||
{{ _('Manage Payments') }}</a>
|
||||
</li>
|
||||
{% if not waffle.switch('disabled-payments') or addon.is_premium() %}
|
||||
<li>
|
||||
<a class="action-link{{ ' alert' if waffle.switch('disabled-payments') and addon.is_premium() }}" href="{{ addon.get_dev_url('payments') }}">
|
||||
{{ _('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 %}
|
||||
<li>
|
||||
<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>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="#" class="more-actions">{{ _('More') }}</a>
|
||||
<div class="more-actions-popup popup hidden">
|
||||
{% 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) %}
|
||||
{% do manage_urls.insert(1,
|
||||
(addon.get_dev_url('refunds'), _('Manage Refunds'))
|
||||
) %}
|
||||
{% endif %}
|
||||
{% if addon.needs_paypal() %}
|
||||
{% do manage_urls.insert(1,
|
||||
(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 manage_urls.insert(1,
|
||||
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
||||
) %}
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for url, title in manage_urls %}
|
||||
<li><a href="{{ url }}">{{ title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
{% if not waffle.switch('disabled-payments') %}
|
||||
<li>
|
||||
<a href="#" class="more-actions">{{ _('More') }}</a>
|
||||
<div class="more-actions-popup popup hidden">
|
||||
{% 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) %}
|
||||
{% do manage_urls.insert(1,
|
||||
(addon.get_dev_url('refunds'), _('Manage Refunds'))
|
||||
) %}
|
||||
{% endif %}
|
||||
{% if addon.needs_paypal() %}
|
||||
{% do manage_urls.insert(1,
|
||||
(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 manage_urls.insert(1,
|
||||
(addon.get_dev_url('in_app_config'), _('Manage In-App Payments'))
|
||||
) %}
|
||||
{% endif %}
|
||||
<ul>
|
||||
{% for url, title in manage_urls %}
|
||||
<li><a href="{{ url }}">{{ title }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% 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 = [
|
||||
(addon.get_dev_url(), _('Edit Listing')),
|
||||
(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. #}
|
||||
{% if addon.is_webapp() %}
|
||||
{% do urls.append((addon.get_dev_url('versions'), _('Manage Status'))) %}
|
||||
{% endif %}
|
||||
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
||||
check_addon_ownership(request, addon, support=True) %}
|
||||
{% do urls.insert(4, (addon.get_dev_url('refunds'), _('Manage Refunds'))) %}
|
||||
{% if not waffle.switch('disabled-payments') or addon.is_premium() %}
|
||||
{% do urls.append((addon.get_dev_url('payments'), _('Manage Payments'))) %}
|
||||
{% endif %}
|
||||
{% if addon.needs_paypal() %}
|
||||
{% 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'))
|
||||
) %}
|
||||
{% if not waffle.switch('disabled-payments') %}
|
||||
{% if waffle.switch('allow-refund') and addon.needs_paypal() and
|
||||
check_addon_ownership(request, addon, support=True) %}
|
||||
{% do urls.insert(4, (addon.get_dev_url('refunds'), _('Manage Refunds'))) %}
|
||||
{% endif %}
|
||||
{% if addon.needs_paypal() %}
|
||||
{% 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 %}
|
||||
{% if request.can_view_consumer %}
|
||||
{% do urls.append(
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||
<h1>{{ title }}</h1>
|
||||
</header>
|
||||
{{ disabled_payments_notice() }}
|
||||
<section class="primary manage" role="main">
|
||||
<div id="in-app-config" class="devhub-form island">
|
||||
<form class="item in-app-config" method="post" action="{{ request.path }}">
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||
<h1>{{ title }}</h1>
|
||||
</header>
|
||||
{{ disabled_payments_notice() }}
|
||||
<section class="primary payments devhub-form" role="main">
|
||||
{% if addon.paypal_id %}
|
||||
<div class="island">
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
{#{{ l10n_menu(addon.default_locale) }}#}
|
||||
<h1>{{ title }}</h1>
|
||||
</header>
|
||||
{{ disabled_payments_notice() }}
|
||||
<section class="primary payments island devhub-form" role="main">
|
||||
<form method="post" action="{{ addon.get_dev_url('payments') }}">
|
||||
{{ csrf() }}
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
{{ hub_breadcrumbs(addon, items=[(None, title)]) }}
|
||||
<h1>{{ title }}</h1>
|
||||
</header>
|
||||
{{ disabled_payments_notice() }}
|
||||
<section id="refunds" class="primary payments devhub-form" role="main">
|
||||
{% if not addon.needs_paypal() %}
|
||||
<div id="enable-payments" class="error item">
|
||||
|
|
|
@ -124,9 +124,6 @@ class TestAppBreadcrumbs(AppHubTest):
|
|||
|
||||
class TestAppDashboard(AppHubTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAppDashboard, self).setUp()
|
||||
|
||||
def test_no_apps(self):
|
||||
Addon.objects.all().delete()
|
||||
r = self.client.get(self.url)
|
||||
|
@ -161,8 +158,7 @@ class TestAppDashboard(AppHubTest):
|
|||
eq_(doc('.more-actions-popup').length, 0)
|
||||
|
||||
def test_action_links(self):
|
||||
waffle.models.Switch.objects.get_or_create(name='app-stats',
|
||||
active=True)
|
||||
self.create_switch('app-stats')
|
||||
app = self.get_app()
|
||||
app.update(public_stats=True)
|
||||
self.make_mine()
|
||||
|
@ -177,10 +173,25 @@ class TestAppDashboard(AppHubTest):
|
|||
amo.tests.check_links([('View Statistics', app.get_stats_url())],
|
||||
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):
|
||||
waffle.models.Switch.objects.create(name='allow-refund', active=True)
|
||||
waffle.models.Switch.objects.create(name='in-app-payments',
|
||||
active=True)
|
||||
self.create_switch('allow-refund')
|
||||
self.create_switch('in-app-payments')
|
||||
app = self.get_app()
|
||||
for status in [amo.ADDON_PREMIUM_INAPP, amo.ADDON_FREE_INAPP]:
|
||||
app.update(premium_type=status)
|
||||
|
@ -192,8 +203,23 @@ class TestAppDashboard(AppHubTest):
|
|||
('Manage PayPal', app.get_dev_url('paypal_setup')),
|
||||
('Manage Refunds', app.get_dev_url('refunds')),
|
||||
]
|
||||
eq_(doc('.status-link').length, 0)
|
||||
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):
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
{{ progress(request, addon=addon, step=step) }}
|
||||
<section id="submit-payments" class="primary">
|
||||
<h2>{{ title }}</h2>
|
||||
{{ disabled_payments_notice() }}
|
||||
<form method="post" class="devhub-form">
|
||||
<div class="brform island swagger c">
|
||||
{{ csrf() }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче