Skip to content

Commit

Permalink
Addons details page (bug 548121, r=jbalogh)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Wenzel committed Mar 11, 2010
1 parent 6e7327c commit 86e440f
Show file tree
Hide file tree
Showing 8 changed files with 671 additions and 12 deletions.
6 changes: 4 additions & 2 deletions apps/addons/helpers.py
Expand Up @@ -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({
Expand Down
10 changes: 10 additions & 0 deletions apps/addons/models.py
Expand Up @@ -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',)
Expand Down Expand Up @@ -395,6 +404,7 @@ class AddonRecommendation(models.Model):

class Meta:
db_table = 'addon_recommendations'
ordering = ('-score',)


class AddonType(amo.models.ModelBase):
Expand Down
11 changes: 6 additions & 5 deletions apps/addons/templates/addons/contribution.html
Expand Up @@ -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">
Expand Down Expand Up @@ -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 %}
Expand All @@ -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>
Expand Down

0 comments on commit 86e440f

Please sign in to comment.