Permalink
Browse files

Addons details page (bug 548121, r=jbalogh)

  • Loading branch information...
fwenzel committed Mar 5, 2010
1 parent 6e7327c commit 86e440fe6ec6aa686862d04a4f2a2e85abf1fb64
View
@@ -61,9 +61,11 @@ def contribution(addon, text='', src='', show_install=False, show_help=True):
"""
# prepare pledge
pledge = addon.pledges.all() and addon.pledges.all()[0] or None
if pledge:
try:
pledge = addon.pledges.ongoing()[0]
src = '%s-pledge-%s' % (src, pledge.id)
except IndexError:
pledge = None
t = env.get_template('addons/contribution.html')
return jinja2.Markup(t.render({
View
@@ -354,13 +354,22 @@ class Meta:
unique_together = ('addon', 'category')
class PledgeManager(amo.models.ManagerBase):
def ongoing(self):
"""Get non-expired pledges only"""
return self.filter(deadline__gte=date.today())
class AddonPledge(amo.models.ModelBase):
addon = models.ForeignKey(Addon, related_name='pledges')
target = models.PositiveIntegerField() # Only $ for now
what_ima_gonna_do = TranslatedField()
active = models.BooleanField(default=False)
deadline = models.DateField(null=True)
objects = PledgeManager()
class Meta:
db_table = 'addons_pledges'
ordering = ('-deadline',)
@@ -395,6 +404,7 @@ class AddonRecommendation(models.Model):
class Meta:
db_table = 'addon_recommendations'
ordering = ('-score',)
class AddonType(amo.models.ModelBase):
@@ -4,8 +4,8 @@
<div class="pledgebox">
{% with target=pledge.target|float|currencyfmt('USD') %}
{# L10n: {0} is a number #}
<h3><em>{{ _('Help the developer of this add-on raise {0} to support '
'its continued development.')|f(target) }}</em></h3>
<h3>{{ _('Help the developer of this add-on raise {0} to support '
'its continued development.')|f(target) }}</h3>
<p>{{ pledge.what_ima_gonna_do }}</p>
<div class="o-meter">
<dl class="raised">
@@ -48,8 +48,8 @@ <h3>{{ text }}</h3>
suggested amount (i.e., only one choice). #}
{% if has_suggested %}id="contribute-button"{% endif %}
href="/addons/contribute/{{ addon.id }}?source={{ src }}">{# TODO reverse URL #}
<img src="{{ MEDIA_URL }}img/amo2009/icons/buttons/heart-blue-16x16.gif"
alt=""/>{{ _('Contribute') }}</a>
<img src="{{ MEDIA_URL }}img/amo2009/icons/buttons/heart-blue-16x16.gif"/>{{
_('Contribute') }}</a>
</a>
{% if show_install %}
@@ -59,7 +59,8 @@ <h3>{{ text }}</h3>
<div class="suggestion">
{% if has_suggested %}
<p>{{ _('Suggested Donation: {0}')|f(addon.suggested_amount) }}</p>
<p>{{ _('Suggested Donation: {0}')|f(
addon.suggested_amount|currencyfmt('USD')) }}</p>
{% endif %}
{% if show_help %}
<p>
Oops, something went wrong.

0 comments on commit 86e440f

Please sign in to comment.