Skip to content

Commit

Permalink
Merge branch 'org-contrib'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Balogh committed Dec 28, 2010
2 parents 38778fd + e3cfb4e commit 599401f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 22 deletions.
2 changes: 1 addition & 1 deletion apps/addons/helpers.py
Expand Up @@ -53,7 +53,7 @@ def performance_note(context, amount, listing=False):

@register.inclusion_tag('addons/contribution.html')
@jinja2.contextfunction
def contribution(context, addon, text='', src='', show_install=False,
def contribution(context, addon, text=None, src='', show_install=False,
show_help=True):
"""
Show a contribution box.
Expand Down
67 changes: 56 additions & 11 deletions apps/addons/templates/addons/contribution.html
@@ -1,3 +1,7 @@
{% if addon.charity %}
{% set charity_url = addon.charity.url %}
{% set charity_name = addon.charity.name %}
{% endif %}
<div class="notification">
{% if pledge %}
{% cache pledge %}
Expand Down Expand Up @@ -38,7 +42,24 @@ <h3>{{ _('Help the developer of this add-on raise {0} to support '
</div>{# /pledgebox #}
{% endcache %}
{% else %}
<h3>{{ text }}</h3>
<h3>
{% if text %}
{{ text }}
{% elif not addon.charity %}
{{ _('The developer of this add-on asks that you help support its '
'continued development by making a small contribution.') }}
{% elif addon.charity_id == amo.FOUNDATION_ORG %}
{% trans %}
The developer of this add-on asks that you show your support
by making a donation to the <a href="{{ charity_url }}">{{ charity_name }}</a>.
{% endtrans %}
{% else %}
{% trans %}
The developer of this add-on asks that you show your support
by making a small contribution to the <a href="{{ charity_url }}">{{ charity_name }}</a>.
{% endtrans %}
{% endif %}
</h3>
{% endif %}

<div class="aux">
Expand Down Expand Up @@ -78,11 +99,27 @@ <h3>{{ text }}</h3>
<input type="hidden" name="source" value="{{ src }}"/>
<h2>{{ _('Make a Contribution') }}</h2>
<p class="support">
{% trans addon_name=addon.name, paypal_url='http://paypal.com' %}
Help support the continued development of <strong>{{
addon_name }}</strong> by making a small contribution through
<a href="{{ paypal_url }}">Paypal</a>.
{% endtrans %}
{% with addon_name=addon.name, paypal_url='http://paypal.com' %}
{% if not addon.charity %}
{% trans %}
Help support the continued development of
<strong>{{ addon_name }}</strong> by making a small contribution
through <a href="{{ paypal_url }}">Paypal</a>.
{% endtrans %}
{% elif addon.charity_id == amo.FOUNDATION_ORG %}
{% trans %}
To show your support for <b>{{ addon_name }}</b>, the developer asks
that you make a donation to the <a href="{{ charity_url }}">{{ charity_name }}</a>
through <a href="{{ paypal_url }}">Paypal</a>.
{% endtrans %}
{% else %}
{% trans %}
To show your support for <b>{{ addon_name }}</b>, the developer asks
that you make a small contribution to the <a href="{{ charity_url }}">{{ charity_name }}</a>
through <a href="{{ paypal_url }}">Paypal</a>.
{% endtrans %}
{% endif %}
{% endwith %}
</p>

<h4>{{ _('How much would you like to contribute?') }}</h4>
Expand Down Expand Up @@ -144,11 +181,19 @@ <h4 class="comment">
<div class="hidden">
<div id="contribute-why" class="popup">
<p class="msg">
{% trans %}
Mozilla is committed to supporting a vibrant and healthy developer
ecosystem. Your optional contribution helps sustain further development
of this add-on.
{% endtrans %}
{% if addon.charity %}
{% trans %}
The developer of this add-on would like you to consider making a
donation to the <a href="{{ charity_url }}">{{ charity_name }}</a>
if you enjoy using it.
{% endtrans %}
{% else %}
{% trans %}
Mozilla is committed to supporting a vibrant and healthy developer
ecosystem. Your optional contribution helps sustain further development
of this add-on.
{% endtrans %}
{% endif %}
</p>
</div>
</div>
5 changes: 1 addition & 4 deletions apps/addons/templates/addons/details.html
Expand Up @@ -56,10 +56,7 @@ <h4 class="author">{{ _('by') }} {{ users_list(addon.listed_authors) }}</h4>
{% endif %}

{% if addon.takes_contributions %}
{{ contribution(addon=addon, src='addon-detail',
text=_('The developer of this add-on asks that you help '
'support its continued development by making a small '
'contribution.')) }}
{{ contribution(addon=addon, src='addon-detail') }}
{% endif %}

<table itemscope itemtype="http://data-vocabulary.org/Review-aggregate">
Expand Down
5 changes: 2 additions & 3 deletions apps/addons/templates/addons/developers.html
Expand Up @@ -16,12 +16,11 @@
{% if page == "installed" %}about{% endif %}
{%- endblock bodyclass %}

{% if page == "roadblock" %}
{% if page == "roadblock" and not addon.charity %}
{% set msg = _('Before downloading this add-on, please consider supporting the '
'development of this add-on by making a small contribution.') %}
{% else %}
{% set msg = _('The developer of this add-on asks that you help support its '
'continued development by making a small contribution.') %}
{% set msg = None %}
{% endif %}

{# contribute/installed is a 'headerless' page, so remove those elements. #}
Expand Down
14 changes: 13 additions & 1 deletion apps/addons/tests/test_views.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
import re
import urlparse

from django import test
from django.conf import settings
Expand All @@ -18,7 +19,7 @@
from amo.urlresolvers import reverse
from amo.tests.test_helpers import AbuseBase, AbuseDisabledBase
from addons import views
from addons.models import Addon, AddonUser
from addons.models import Addon, AddonUser, Charity
from files.models import File
from users.helpers import users_list
from users.models import UserProfile
Expand Down Expand Up @@ -253,6 +254,17 @@ def test_unicode_comment(self):
eq_(r.status_code, 302)
assert r['Location'].startswith(settings.PAYPAL_CGI_URL)

def test_organization(self):
c = Charity.objects.create(name='moz', url='moz.com', paypal='mozcom')
addon = Addon.objects.get(id=592)
addon.update(charity=c)

r = self.client.get(reverse('addons.contribute', args=['a592']))
eq_(r.status_code, 302)
qs = dict(urlparse.parse_qsl(r['Location']))
eq_(qs['item_name'], 'Contribution for moz')
eq_(qs['business'], 'mozcom')


class TestDeveloperPages(test_utils.TestCase):
fixtures = ['base/apps', 'base/addon_3615', 'base/addon_592',
Expand Down
9 changes: 7 additions & 2 deletions apps/addons/views.py
Expand Up @@ -12,6 +12,7 @@

import caching.base as caching
import jingo
import jinja2
import commonware.log

from tower import ugettext_lazy as _lazy
Expand Down Expand Up @@ -397,9 +398,13 @@ def contribute(request, addon):
return_url = "%s?%s" % (reverse('addons.thanks', args=[addon.slug]),
urllib.urlencode({'uuid': contribution_uuid}))
# L10n: {0} is an add-on name.
contrib_for = _(u'Contribution for {0}').format(addon.name)
if addon.charity:
name, paypal = addon.charity.name, addon.charity.paypal
else:
name, paypal = addon.name, addon.paypal_id
contrib_for = _(u'Contribution for {0}').format(jinja2.escape(name))
redirect_url_params = contribute_url_params(
addon.paypal_id,
paypal,
addon.id,
contrib_for,
absolutify(return_url),
Expand Down

0 comments on commit 599401f

Please sign in to comment.