diff --git a/apps/amo/tests/__init__.py b/apps/amo/tests/__init__.py index 9403d6c0be..a85d739d5f 100644 --- a/apps/amo/tests/__init__.py +++ b/apps/amo/tests/__init__.py @@ -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) diff --git a/media/css/devreg/devhub-forms.less b/media/css/devreg/devhub-forms.less index bca4557d6b..5a70dac873 100644 --- a/media/css/devreg/devhub-forms.less +++ b/media/css/devreg/devhub-forms.less @@ -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; diff --git a/media/css/devreg/lib.less b/media/css/devreg/lib.less index e28e00809f..a31be3ca69 100644 --- a/media/css/devreg/lib.less +++ b/media/css/devreg/lib.less @@ -9,6 +9,7 @@ @black: #000; @white: #fff; @red: #C63717; +@maroon: #800; @error-red: #C00000; @orange: #D16B00; @notice-yellow: #FAF2BD; diff --git a/mkt/developers/helpers.py b/mkt/developers/helpers.py index ba9c94b2ca..883791c70f 100644 --- a/mkt/developers/helpers.py +++ b/mkt/developers/helpers.py @@ -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')} diff --git a/mkt/developers/templates/developers/apps/listing/item_actions_app.html b/mkt/developers/templates/developers/apps/listing/item_actions_app.html index cc7b7ccfcb..839bbe4dcc 100644 --- a/mkt/developers/templates/developers/apps/listing/item_actions_app.html +++ b/mkt/developers/templates/developers/apps/listing/item_actions_app.html @@ -28,10 +28,17 @@
  • {{ _('Manage Authors') }}
  • -
  • - - {{ _('Manage Payments') }} -
  • + {% if not waffle.switch('disabled-payments') or addon.is_premium() %} +
  • + + {{ _('Manage Payments') }} +
  • + {% endif %} + {% if waffle.switch('disabled-payments') %} +
  • + {{ _('Manage Status') }} +
  • + {% endif %} {% if request.can_view_consumer %}
  • {{ _('View Listing') }} @@ -42,34 +49,36 @@ {{ _('View Statistics') }}
  • {% endif %} -
  • - {{ _('More') }} - -
  • + {% if not waffle.switch('disabled-payments') %} +
  • + {{ _('More') }} + +
  • + {% endif %} {% endif %} diff --git a/mkt/developers/templates/developers/helpers/disabled_payments_notice.html b/mkt/developers/templates/developers/helpers/disabled_payments_notice.html new file mode 100644 index 0000000000..0ee6068d15 --- /dev/null +++ b/mkt/developers/templates/developers/helpers/disabled_payments_notice.html @@ -0,0 +1,18 @@ +{% if waffle.switch('disabled-payments') %} +
    +

    + {% 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, payments are currently disabled but are coming soon. + If you would like users to be able to install your app, please, + for the time being, make your app free. + You will be notified via email when payments are re-enabled. + Thanks for your patience. + {% endtrans %} +

    +
    +{% endif %} diff --git a/mkt/developers/templates/developers/includes/addons_edit_nav.html b/mkt/developers/templates/developers/includes/addons_edit_nav.html index 398ae853f4..70601db45e 100644 --- a/mkt/developers/templates/developers/includes/addons_edit_nav.html +++ b/mkt/developers/templates/developers/includes/addons_edit_nav.html @@ -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( diff --git a/mkt/developers/templates/developers/payments/in-app-config.html b/mkt/developers/templates/developers/payments/in-app-config.html index 54fbaa6d13..41c56a1c6f 100644 --- a/mkt/developers/templates/developers/payments/in-app-config.html +++ b/mkt/developers/templates/developers/payments/in-app-config.html @@ -14,6 +14,7 @@ {{ hub_breadcrumbs(addon, items=[(None, title)]) }}

    {{ title }}

    +{{ disabled_payments_notice() }}
    diff --git a/mkt/developers/templates/developers/payments/paypal-setup.html b/mkt/developers/templates/developers/payments/paypal-setup.html index 53d2d5316f..fb4029732d 100644 --- a/mkt/developers/templates/developers/payments/paypal-setup.html +++ b/mkt/developers/templates/developers/payments/paypal-setup.html @@ -13,6 +13,7 @@ {{ hub_breadcrumbs(addon, items=[(None, title)]) }}

    {{ title }}

    + {{ disabled_payments_notice() }}
    {% if addon.paypal_id %}
    diff --git a/mkt/developers/templates/developers/payments/premium.html b/mkt/developers/templates/developers/payments/premium.html index 830b2adba9..4070f70b66 100644 --- a/mkt/developers/templates/developers/payments/premium.html +++ b/mkt/developers/templates/developers/payments/premium.html @@ -15,6 +15,7 @@ {#{{ l10n_menu(addon.default_locale) }}#}

    {{ title }}

    + {{ disabled_payments_notice() }}
    {{ csrf() }} diff --git a/mkt/developers/templates/developers/payments/refunds.html b/mkt/developers/templates/developers/payments/refunds.html index 12e1d3b9e0..3214c3e2ac 100644 --- a/mkt/developers/templates/developers/payments/refunds.html +++ b/mkt/developers/templates/developers/payments/refunds.html @@ -68,6 +68,7 @@ {{ hub_breadcrumbs(addon, items=[(None, title)]) }}

    {{ title }}

    + {{ disabled_payments_notice() }}
    {% if not addon.needs_paypal() %}
    diff --git a/mkt/developers/tests/test_views.py b/mkt/developers/tests/test_views.py index ab5a8f17d1..2da2002cc4 100644 --- a/mkt/developers/tests/test_views.py +++ b/mkt/developers/tests/test_views.py @@ -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): diff --git a/mkt/submit/templates/submit/payments.html b/mkt/submit/templates/submit/payments.html index ce9a14eea9..fb47576e0c 100644 --- a/mkt/submit/templates/submit/payments.html +++ b/mkt/submit/templates/submit/payments.html @@ -10,6 +10,7 @@ {{ progress(request, addon=addon, step=step) }}

    {{ title }}

    + {{ disabled_payments_notice() }}
    {{ csrf() }}