From 1b9b02daedff88520192e98a729d0bdb078305ed Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Wed, 10 Aug 2011 17:27:54 +0100 Subject: [PATCH] allow voluntary, marketplace choice, add in docs (bug 677530) --- .../templates/devhub/addons/payments.html | 135 ------------------ .../devhub/docs/marketplace-voluntary.html | 0 .../templates/devhub/docs/marketplace.html | 3 + .../devhub/payments/marketplace-confirm.html | 22 +++ .../templates/devhub/payments/payments.html | 92 ++++++++++++ .../templates/devhub/payments/voluntary.html | 70 +++++++++ apps/devhub/tests/test_views.py | 36 ++++- apps/devhub/views.py | 5 +- media/css/zamboni/developers.css | 11 +- media/js/zamboni/devhub.js | 10 ++ 10 files changed, 243 insertions(+), 141 deletions(-) delete mode 100644 apps/devhub/templates/devhub/addons/payments.html create mode 100644 apps/devhub/templates/devhub/docs/marketplace-voluntary.html create mode 100644 apps/devhub/templates/devhub/docs/marketplace.html create mode 100644 apps/devhub/templates/devhub/payments/marketplace-confirm.html create mode 100644 apps/devhub/templates/devhub/payments/payments.html create mode 100644 apps/devhub/templates/devhub/payments/voluntary.html diff --git a/apps/devhub/templates/devhub/addons/payments.html b/apps/devhub/templates/devhub/addons/payments.html deleted file mode 100644 index 7a102ef1bfc..00000000000 --- a/apps/devhub/templates/devhub/addons/payments.html +++ /dev/null @@ -1,135 +0,0 @@ -{% extends "devhub/base.html" %} - -{% set title = _('Manage Payments') %} -{% block title %}{{ dev_page_title(title, addon) }}{% endblock %} - -{% set can_edit = (addon.status == amo.STATUS_PUBLIC - and check_addon_ownership(request, addon)) %} -{% block bodyclass %} - {{ super() }}{% if not can_edit %} no-edit{% endif %} -{% endblock %} - -{% block content %} -
- {{ dev_breadcrumbs(addon, items=[(None, title)]) }} - {{ l10n_menu(addon.default_locale) }} -

{{ title }}

-
-
- - {% if not can_edit or not addon.has_full_profile() %} -
-

- {% trans url=url('devhub.addons.profile', addon.slug) %} - Payments are only available for fully reviewed add-ons with a completed developer profile. - {% endtrans %} -

-
- {% endif %} - - {% set contrib = addon.takes_contributions and addon.has_full_profile() or errors %} - {% if contrib and not errors %} -
-

- {{ _('You are currently requesting contributions from users')|safe }} -
- - {% trans url=url('addons.about', addon.slug), - url_full=url('addons.about', addon.slug, host=settings.SITE_URL) %} - Your contribution page: {{ url_full }} - {% endtrans %} - -

-
- {{ csrf() }} - -
-
- {% elif not errors %} -
-

{{ _('Contributions') }}

-

{{ _('Voluntary contributions provide a way for users to support your add-on financially. With contributions, you can:') }}

-
    -
  • {{ _('Ask for contributions in most places your add-on appears') }}
  • -
  • {{ _('Allow users to make payments with a credit card or PayPal account') }}
  • -
  • {{ _('Receive contributions in your PayPal account or send them to an organization of your choice') }}
  • -
- -
- {% endif %} - -
-

{{ _('Contributions') if contrib else _('Set up Contributions') }}

-

{{ _('Fill in the fields below to begin asking for voluntary contributions from users.') }}

-
- {{ csrf() }} - {% set values = contrib_form.data if contrib_form.is_bound else contrib_form.initial %} -
- {{ contrib_form.non_field_errors() }} - {{ contrib_form.recipient.errors }} - {{ _('Who will receive contributions to this add-on?') }} - {{ contrib_form.recipient }} -
- {{ charity_form.non_field_errors() }} - {{ charity_form.name.errors }} - - {{ charity_form.name }} - {{ charity_form.url.errors }} - - {{ charity_form.url }} - {{ charity_form.paypal.errors }} - - {{ charity_form.paypal }} -
-
-
- {{ contrib_form.paypal_id.errors }} - -
{{ contrib_form.paypal_id }} {{ _('Sign up for Paypal') }}
-
-
- {{ contrib_form.suggested_amount.errors }} - -
{{ contrib_form.suggested_amount.help_text }}
-
{{ contrib_form.suggested_amount }} USD {{ _('(Example: 3.99)') }}
-
-
- {{ contrib_form.annoying.errors }} - {{ _('When should users be asked for contributions?') }} -
{{ contrib_form.annoying.help_text }}
- {{ contrib_form.annoying }} -
-
- {{ _('Send a thank-you note?') }}
- {{ contrib_form.enable_thankyou }} - -
-
{% trans %} - We recommend thanking the user and telling them how much you appreciate their - support. You might also want to tell them about what's next for your add-on and - about any other add-ons you've made for them to try. - {% endtrans %}
- {{ contrib_form.thankyou_note.errors }} - {{ contrib_form.thankyou_note }} - -
-
- {% if not addon.has_full_profile() %} - {% with slim=True %} - {% include "devhub/includes/addons_create_profile.html" %} - {% endwith %} - {% endif %} - - - {% trans %} - or Cancel - {% endtrans %} - -
-
-
-{% include "devhub/includes/addons_edit_nav.html" %} -{% endblock %} diff --git a/apps/devhub/templates/devhub/docs/marketplace-voluntary.html b/apps/devhub/templates/devhub/docs/marketplace-voluntary.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/apps/devhub/templates/devhub/docs/marketplace.html b/apps/devhub/templates/devhub/docs/marketplace.html new file mode 100644 index 00000000000..ef4ed144d67 --- /dev/null +++ b/apps/devhub/templates/devhub/docs/marketplace.html @@ -0,0 +1,3 @@ +{% extends "devhub/base.html" %} + +{% block title %}{{ docs_page_title(_('Marketplace')) }}{% endblock %} diff --git a/apps/devhub/templates/devhub/payments/marketplace-confirm.html b/apps/devhub/templates/devhub/payments/marketplace-confirm.html new file mode 100644 index 00000000000..a6a3291ecb3 --- /dev/null +++ b/apps/devhub/templates/devhub/payments/marketplace-confirm.html @@ -0,0 +1,22 @@ + diff --git a/apps/devhub/templates/devhub/payments/payments.html b/apps/devhub/templates/devhub/payments/payments.html new file mode 100644 index 00000000000..614962effae --- /dev/null +++ b/apps/devhub/templates/devhub/payments/payments.html @@ -0,0 +1,92 @@ +{% extends "devhub/base.html" %} + +{% set title = _('Manage Payments') %} +{% block title %}{{ dev_page_title(title, addon) }}{% endblock %} + +{% set can_edit = (addon.status == amo.STATUS_PUBLIC + and check_addon_ownership(request, addon)) %} +{% block bodyclass %} + {{ super() }}{% if not can_edit %} no-edit{% endif %} +{% endblock %} + +{% block content %} +
+ {{ dev_breadcrumbs(addon, items=[(None, title)]) }} + {{ l10n_menu(addon.default_locale) }} +

{{ title }}

+
+
+ + {% if not can_edit or not addon.has_full_profile() %} +
+

+ {% trans url=url('devhub.addons.profile', addon.slug) %} + Payments are only available for fully reviewed add-ons with a completed developer profile. + {% endtrans %} +

+
+ {% endif %} + + {% set contrib = addon.takes_contributions and addon.has_full_profile() or errors %} + {% if contrib and not errors %} +
+

+ {{ _('You are currently requesting contributions from users')|safe }} +
+ + {% trans url=url('addons.about', addon.slug), + url_full=url('addons.about', addon.slug, host=settings.SITE_URL) %} + Your contribution page: {{ url_full }} + {% endtrans %} + +

+
+ {{ csrf() }} + +
+
+ {% elif not errors %} +
+

{{ _('Voluntary Contributions') }}

+

{{ _('Add-ons enrolled in our contributions program can request voluntary finanical support from users.') }}

+
    +
  • {{ _('Encourage users to support your add-on through your Developer Profile') }}
  • +
  • {{ _('Choose when and how users are asked to contribute') }}
  • +
  • {{ _('Receive contributions in your PayPal account or send them to an organization of your choice') }}
  • +
+ + {% if waffle.switch('marketplace') %} +
+ {% trans doc_url=url('devhub.docs', doc_name='marketplace', doc_page='voluntary') %}or learn more{% endtrans %} +
+ {% endif %} +
+ {% if waffle.switch('marketplace') and addon.can_become_premium() %} +
+

{{ _('Mozilla Marketplace') }}

+

{{ _('Premium add-ons can be sold in our marketplace by themselves or as an upgrade to a free version of your add-on.') }}

+
    +
  • {{ _('Set your price and place your add-on for sale') }}
  • +
  • {{ _('Users pay with their credit card or PayPal account all over the world') }}
  • +
  • {{ _('Receive funds immediately in your PayPal account') }}
  • +
  • {{ _("Promote your premium add-on on your free add-on's details page") }}
  • +
+ +
+ {% trans doc_url=url('devhub.docs', doc_name='marketplace') %}or learn more{% endtrans %} +
+
+ {% endif %} + {% endif %} + + {% include "devhub/payments/voluntary.html" %} + {% if waffle.switch('marketplace') and addon.can_become_premium() %} + {% include "devhub/payments/marketplace-confirm.html" %} + {% endif %} +
+{% include "devhub/includes/addons_edit_nav.html" %} +{% endblock %} diff --git a/apps/devhub/templates/devhub/payments/voluntary.html b/apps/devhub/templates/devhub/payments/voluntary.html new file mode 100644 index 00000000000..9da2a2143f3 --- /dev/null +++ b/apps/devhub/templates/devhub/payments/voluntary.html @@ -0,0 +1,70 @@ +
+

{{ _('Contributions') if contrib else _('Set up Contributions') }}

+

{{ _('Fill in the fields below to begin asking for voluntary contributions from users.') }}

+
+ {{ csrf() }} + {% set values = contrib_form.data if contrib_form.is_bound else contrib_form.initial %} +
+ {{ contrib_form.non_field_errors() }} + {{ contrib_form.recipient.errors }} + {{ _('Who will receive contributions to this add-on?') }} + {{ contrib_form.recipient }} +
+ {{ charity_form.non_field_errors() }} + {{ charity_form.name.errors }} + + {{ charity_form.name }} + {{ charity_form.url.errors }} + + {{ charity_form.url }} + {{ charity_form.paypal.errors }} + + {{ charity_form.paypal }} +
+
+
+ {{ contrib_form.paypal_id.errors }} + +
{{ contrib_form.paypal_id }} {{ _('Sign up for Paypal') }}
+
+
+ {{ contrib_form.suggested_amount.errors }} + +
{{ contrib_form.suggested_amount.help_text }}
+
{{ contrib_form.suggested_amount }} USD {{ _('(Example: 3.99)') }}
+
+
+ {{ contrib_form.annoying.errors }} + {{ _('When should users be asked for contributions?') }} +
{{ contrib_form.annoying.help_text }}
+ {{ contrib_form.annoying }} +
+
+ {{ _('Send a thank-you note?') }}
+ {{ contrib_form.enable_thankyou }} + +
+
{% trans %} + We recommend thanking the user and telling them how much you appreciate their + support. You might also want to tell them about what's next for your add-on and + about any other add-ons you've made for them to try. + {% endtrans %}
+ {{ contrib_form.thankyou_note.errors }} + {{ contrib_form.thankyou_note }} + +
+
+ {% if not addon.has_full_profile() %} + {% with slim=True %} + {% include "devhub/includes/addons_create_profile.html" %} + {% endwith %} + {% endif %} + + + {% trans %} + or Cancel + {% endtrans %} + +
+
diff --git a/apps/devhub/tests/test_views.py b/apps/devhub/tests/test_views.py index 9d9240f010f..5d898f6f06f 100644 --- a/apps/devhub/tests/test_views.py +++ b/apps/devhub/tests/test_views.py @@ -669,13 +669,47 @@ def check_page(request): eq_(self.get_addon().wants_contributions, False) +class TestMarketplace(amo.tests.TestCase): + fixtures = ['base/apps', 'base/users', 'base/addon_3615'] + + def setUp(self): + self.addon = Addon.objects.get(id=3615) + self.url = reverse('devhub.addons.payments', args=[self.addon.slug]) + assert self.client.login(username='del@icio.us', password='password') + + self.marketplace = (waffle.models.Switch.objects + .get_or_create(name='marketplace')[0]) + self.marketplace.active = True + self.marketplace.save() + + def tearDown(self): + self.marketplace.active = False + self.marketplace.save() + + @mock.patch('addons.models.Addon.can_become_premium') + def test_ask_page(self, can_become_premium): + can_become_premium.return_value = True + res = self.client.get(self.url) + eq_(res.status_code, 200) + doc = pq(res.content) + eq_(len(doc('div.intro')), 2) + + @mock.patch('addons.models.Addon.can_become_premium') + def test_cant_become_premium(self, can_become_premium): + can_become_premium.return_value = False + res = self.client.get(self.url) + eq_(res.status_code, 200) + doc = pq(res.content) + eq_(len(doc('div.intro')), 1) + + class TestDelete(amo.tests.TestCase): fixtures = ('base/apps', 'base/users', 'base/addon_3615', 'base/addon_5579',) def setUp(self): self.addon = self.get_addon() - assert self.client.login(username='del@icio.us', password='password') + self.url = reverse('devhub.addons.delete', args=[self.addon.slug]) def get_addon(self): diff --git a/apps/devhub/views.py b/apps/devhub/views.py index 5e3109d6f9d..0ea3b177702 100644 --- a/apps/devhub/views.py +++ b/apps/devhub/views.py @@ -412,7 +412,7 @@ def payments(request, addon_id, addon): errors = charity_form.errors or contrib_form.errors or profile_form.errors if errors: messages.error(request, _('There were errors in your submission.')) - return jingo.render(request, 'devhub/addons/payments.html', + return jingo.render(request, 'devhub/payments/payments.html', dict(addon=addon, charity_form=charity_form, errors=errors, contrib_form=contrib_form, profile_form=profile_form)) @@ -1384,6 +1384,9 @@ def docs(request, doc_name=None, doc_page=None): 'how-to': ['getting-started', 'extension-development', 'thunderbird-mobile', 'theme-development', 'other-addons']} + + if waffle.switch_is_active('marketplace'): + all_docs['marketplace'] = ['voluntary'] if doc_name and doc_name in all_docs: filename = '%s.html' % doc_name diff --git a/media/css/zamboni/developers.css b/media/css/zamboni/developers.css index e8d41f45cd7..806bc7c677a 100644 --- a/media/css/zamboni/developers.css +++ b/media/css/zamboni/developers.css @@ -56,6 +56,7 @@ form .char-count:after, } #setup h3, +#marketplace-confirm h3, .addon-submission-process > h3, .developer-hub .primary > h3 { margin-top: 0; @@ -970,6 +971,7 @@ input.valid { -webkit-border-radius: 8px; border-radius: 8px; display: inline-block; + vertical-align: top; } .payments .intro ul { list-style-type: disc; @@ -984,9 +986,13 @@ input.valid { .payments .intro p { font-size: .9em; } -.payments .intro .button-wrapper { +.payments .intro .button-wrapper, +.payments .learn-more { text-align: center; } +.payments .indent { + padding-left: 2em; +} .devhub-form .brform label, .devhub-form .b { font-weight: 500; @@ -1001,9 +1007,6 @@ input.valid { .payments form > div { margin-bottom: 2em; } -.paypal { - margin-left: 2em; -} .extra { font-size: .9em; } diff --git a/media/js/zamboni/devhub.js b/media/js/zamboni/devhub.js index bde1c2f2d69..0e03d93d606 100644 --- a/media/js/zamboni/devhub.js +++ b/media/js/zamboni/devhub.js @@ -748,6 +748,16 @@ function initPayments() { $(".intro").show(); $("#setup").hide(); }); + $("#do-marketplace").click(function (e) { + e.preventDefault(); + $("#marketplace-confirm").removeClass("hidden").show(); + $(".intro").hide(); + }); + $("#marketplace-cancel").click(function (e) { + e.preventDefault(); + $(".intro").show(); + $("#marketplace-confirm").hide(); + }); $(".recipient").change(function (e) { var v = $(this).val(); $(".paypal").hide(200);