Skip to content

Commit

Permalink
allow voluntary, marketplace choice, add in docs (bug 677530)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy McKay committed Aug 16, 2011
1 parent b3279bd commit 1b9b02d
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 141 deletions.
135 changes: 0 additions & 135 deletions apps/devhub/templates/devhub/addons/payments.html

This file was deleted.

Empty file.
3 changes: 3 additions & 0 deletions apps/devhub/templates/devhub/docs/marketplace.html
@@ -0,0 +1,3 @@
{% extends "devhub/base.html" %}

{% block title %}{{ docs_page_title(_('Marketplace')) }}{% endblock %}
22 changes: 22 additions & 0 deletions apps/devhub/templates/devhub/payments/marketplace-confirm.html
@@ -0,0 +1,22 @@
<div id="marketplace-confirm" class="hidden">
<h3>{{ _('Mozilla Marketplace') }}</h3>
<p>{% trans doc_url=url('devhub.docs', doc_name='marketplace'),
agree_url=url('devhub.docs', doc_name='policies', doc_page='agreement') %}
Thanks for your interest in selling your add-on in the Mozilla Marketplace.
Please be sure to read our <a href="{{ doc_url }}">Marketplace Documentation and Policies</a>
before continuing, as well as the <a href="{{ agree_url }}">Developer Agreement</a> you agreed
to when first submitting this add-on.
{% endtrans %}</p>
<p>{% trans %}Please confirm this is the premium add-on you wish to sell.{% endtrans %}</p>
<div class="indent">
<h4>{{ addon.name }}</h4>
<p>{{ addon.guid }}</p>
</div>
<p>{% trans %}If this is the free version of your add-on, please create a new UUID
for your premium add-on and submit it seperately before enrolling in Mozilla Marketplace.
{% endtrans %}</p>
<button id="marketplace-submit" type="submit">{{ _('Sell this Add-on') }}</button>
{% trans %}
or <a id="marketplace-cancel" href="#">Cancel</a>
{% endtrans %}
</div>
92 changes: 92 additions & 0 deletions 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 %}
<header>
{{ dev_breadcrumbs(addon, items=[(None, title)]) }}
{{ l10n_menu(addon.default_locale) }}
<h2>{{ title }}</h2>
</header>
<section class="primary payments devhub-form" role="main">

{% if not can_edit or not addon.has_full_profile() %}
<div class="notification-box warning">
<h2>
{% trans url=url('devhub.addons.profile', addon.slug) %}
Payments are only available for fully reviewed add-ons with a <a href="{{ url }}">completed developer profile</a>.
{% endtrans %}
</h2>
</div>
{% endif %}

{% set contrib = addon.takes_contributions and addon.has_full_profile() or errors %}
{% if contrib and not errors %}
<div id="status-bar">
<p>
{{ _('You are currently requesting <b>contributions</b> from users')|safe }}
<br>
<span class="light">
{% trans url=url('addons.about', addon.slug),
url_full=url('addons.about', addon.slug, host=settings.SITE_URL) %}
Your contribution page: <a href="{{ url }}">{{ url_full }}</a>
{% endtrans %}
</span>
</p>
<form method="post" action="{{ url('devhub.addons.payments.disable', addon.slug) }}">
{{ csrf() }}
<button type="submit">{{ _('Disable Contributions') }}</button>
</form>
</div>
{% elif not errors %}
<div class="intro">
<h3>{{ _('Voluntary Contributions') }}</h3>
<p>{{ _('Add-ons enrolled in our contributions program can request voluntary finanical support from users.') }}</p>
<ul>
<li>{{ _('Encourage users to support your add-on through your Developer Profile') }}</li>
<li>{{ _('Choose when and how users are asked to contribute') }}</li>
<li>{{ _('Receive contributions in your PayPal account or send them to an organization of your choice') }}</li>
</ul>
<div class="button-wrapper">
<a href="#setup" id="do-setup" class="button prominent">{{ _('Set up Contributions') }}</a>
</div>
{% if waffle.switch('marketplace') %}
<div class="learn-more">
{% trans doc_url=url('devhub.docs', doc_name='marketplace', doc_page='voluntary') %}or <a href="{{ doc_url }}">learn more</a>{% endtrans %}
</div>
{% endif %}
</div>
{% if waffle.switch('marketplace') and addon.can_become_premium() %}
<div class="intro">
<h3>{{ _('Mozilla Marketplace') }}</h3>
<p>{{ _('Premium add-ons can be sold in our marketplace by themselves or as an upgrade to a free version of your add-on.') }}</p>
<ul>
<li>{{ _('Set your price and place your add-on for sale') }}</li>
<li>{{ _('Users pay with their credit card or PayPal account all over the world') }}</li>
<li>{{ _('Receive funds immediately in your PayPal account') }}</li>
<li>{{ _("Promote your premium add-on on your free add-on's details page") }}</li>
</ul>
<div class="button-wrapper">
<a href="#marketplace-confirm" id="do-marketplace" class="button prominent">{{ _('Enroll in Marketplace') }}</a>
</div>
<div class="learn-more">
{% trans doc_url=url('devhub.docs', doc_name='marketplace') %}or <a href="{{ doc_url }}">learn more</a>{% endtrans %}
</div>
</div>
{% endif %}
{% endif %}

{% include "devhub/payments/voluntary.html" %}
{% if waffle.switch('marketplace') and addon.can_become_premium() %}
{% include "devhub/payments/marketplace-confirm.html" %}
{% endif %}
</section>
{% include "devhub/includes/addons_edit_nav.html" %}
{% endblock %}
70 changes: 70 additions & 0 deletions apps/devhub/templates/devhub/payments/voluntary.html
@@ -0,0 +1,70 @@
<div id="setup" class="{{ 'hidden' if not contrib }}">
<h3>{{ _('Contributions') if contrib else _('Set up Contributions') }}</h3>
<p class="{{ 'hidden' if contrib }}">{{ _('Fill in the fields below to begin asking for voluntary contributions from users.') }}</p>
<form id="payments-setup-form" method="post" action="{{ url('devhub.addons.payments', addon.slug) }}">
{{ csrf() }}
{% set values = contrib_form.data if contrib_form.is_bound else contrib_form.initial %}
<div>
{{ contrib_form.non_field_errors() }}
{{ contrib_form.recipient.errors }}
<b>{{ _('Who will receive contributions to this add-on?') }}</b>
{{ contrib_form.recipient }}
<div id="org-org" class="brform paypal {{ 'hidden' if (values.recipient != 'org') }}">
{{ charity_form.non_field_errors() }}
{{ charity_form.name.errors }}
<label for="id_charity-name">{{ _('What is the name of the organization?') }}</label>
{{ charity_form.name }}
{{ charity_form.url.errors }}
<label for="id_charity-url">{{ _('What is the URL of the organization?') }}</label>
{{ charity_form.url }}
{{ charity_form.paypal.errors }}
<label for="id_charity-paypal">{{ _('What is the PayPal ID of the organization?') }}</label>
{{ charity_form.paypal }}
</div>
</div>
<div id="org-dev" class="brform paypal {{ 'hidden' if (values.recipient != 'dev') }}">
{{ contrib_form.paypal_id.errors }}
<label for="id_paypal_id">{{ _('What is your PayPal ID?') }}</label>
<div>{{ contrib_form.paypal_id }} <a class="extra" href="{{ settings.PAYPAL_CGI_URL + '?cmd=_registration-run' }}">{{ _('Sign up for Paypal') }}</a></div>
</div>
<div class="brform">
{{ contrib_form.suggested_amount.errors }}
<label for="id_suggested_amount">{{ _('What is your suggested contribution?') }}</label>
<div class="extra">{{ contrib_form.suggested_amount.help_text }}</div>
<div>{{ contrib_form.suggested_amount }} USD {{ _('(Example: 3.99)') }}</div>
</div>
<div class="nag">
{{ contrib_form.annoying.errors }}
<b>{{ _('When should users be asked for contributions?') }}</b>
<div class="extra">{{ contrib_form.annoying.help_text }}</div>
{{ contrib_form.annoying }}
</div>
<div>
<b>{{ _('Send a thank-you note?') }}</b><br>
{{ contrib_form.enable_thankyou }}
<label for="{{ contrib_form.enable_thankyou.auto_id }}">
{{ _("We'll automatically email users who contribute to your add-on with this message.") }}</label>
<div class="thankyou-note {{ 'hidden' if not contrib_form.initial.enable_thankyou }}">
<div class="extra">{% 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 %}</div>
{{ contrib_form.thankyou_note.errors }}
{{ contrib_form.thankyou_note }}
<label data-for="thankyou_note"></label>
</div>
</div>
{% if not addon.has_full_profile() %}
{% with slim=True %}
{% include "devhub/includes/addons_create_profile.html" %}
{% endwith %}
{% endif %}
<button type="submit">{{ _('Save Changes') if contrib else _('Activate Contributions') }}</button>
<span class="{{ 'hidden' if contrib }}">
{% trans %}
or <a id="setup-cancel" href="#">Cancel</a>
{% endtrans %}
</span>
</form>
</div>
36 changes: 35 additions & 1 deletion apps/devhub/tests/test_views.py
Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion apps/devhub/views.py
Expand Up @@ -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))

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1b9b02d

Please sign in to comment.