Skip to content

Commit

Permalink
impala details page stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
potch committed May 4, 2011
1 parent 2d36a61 commit 5dc1cfe
Show file tree
Hide file tree
Showing 50 changed files with 1,286 additions and 160 deletions.
26 changes: 25 additions & 1 deletion apps/addons/helpers.py
Expand Up @@ -57,10 +57,34 @@ def performance_note(context, amount, listing=False):
return new_context(**locals())


@register.inclusion_tag('addons/impala/performance_note.html')
@jinja2.contextfunction
def impala_performance_note(context, amount, listing=False):
return new_context(**locals())


@register.inclusion_tag('addons/contribution.html')
@jinja2.contextfunction
def contribution(context, addon, text=None, src='', show_install=False,
show_help=True):
show_help=True, large=False):
"""
Show a contribution box.
Parameters:
addon
text: The begging text at the top of the box.
src: The page where the contribution link is coming from.
show_install: Whether or not to show the install button.
show_help: Show "What's this?" link?
"""
has_suggested = bool(addon.suggested_amount)
return new_context(**locals())


@register.inclusion_tag('addons/impala/contribution.html')
@jinja2.contextfunction
def impala_contribution(context, addon, text=None, src='', show_install=False,
show_help=True, large=False):
"""
Show a contribution box.
Expand Down
4 changes: 3 additions & 1 deletion apps/addons/models.py
Expand Up @@ -346,7 +346,9 @@ def flush_urls(self):

return urls

def get_url_path(self):
def get_url_path(self, impala=False):
if impala:
return reverse('addons.i_detail', args=[self.slug])
return reverse('addons.detail', args=[self.slug])

def meet_the_dev_url(self):
Expand Down
2 changes: 1 addition & 1 deletion apps/addons/templates/addons/impala/addon_grid.html
Expand Up @@ -6,7 +6,7 @@
{% for addon in page %}
<li>
<div class="item">
<a href="{{ addon.get_url_path() }}">
<a href="{{ addon.get_url_path(impala=True) }}">
<div class="icon">
{% if first_page %}
<img src="{{ addon.icon_url }}">
Expand Down
176 changes: 176 additions & 0 deletions apps/addons/templates/addons/impala/contribution.html
@@ -0,0 +1,176 @@
{% if addon.charity %}
{% set charity_url = addon.charity.outgoing_url %}
{% set charity_name = addon.charity.name %}
{% endif %}

<div class="notice c" id="contribution">
<div class="aux{% if show_install %}-bottom{% endif %}">
<div class="button-wrapper">
<a class="button contribute prominent" id="contribute-button"
href="{{ url('addons.contribute', addon.slug)|urlparams(src=src) }}">
<b></b>{{ _('Contribute') }}
</a>
{% if show_install %}
{# L10n: Click Contribute button OR Install button #}
<span class="continue">{{ _('or') }}</span>
{% set ver = version or None %}
{{ install_button(addon, version=ver, show_contrib=False) }}
{% endif %}

</div>{# /button-wrapper #}

<p class="suggestion">
{% if has_suggested %}
{% trans amt = addon.suggested_amount|currencyfmt('USD') %}
<b>{{ amt }}</b> suggested
{% endtrans %}
{% endif %}
</p>{# /suggestion #}
</div>{# /aux #}

<h3>{{ _('Enjoy this add-on?') }}</h3>
<p class="{% if show_install %}show-install{% endif %}">
{% 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 <a href="{{ charity_url }}">{{ charity_name }}</a>.
{% endtrans %}
{% endif %}
</p>

<div id="contribute-box" class="jqmWindow">
<form action="{{ url('addons.contribute', addon.slug) }}" method="get">
<input type="hidden" name="source" value="{{ request.GET.get('src', src) }}"/>
<h2>{{ _('Make a Contribution') }}</h2>
<p class="support">
{% 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 <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>
<div class="error" id="contrib-too-much"
data-max-amount="{{ settings.MAX_CONTRIBUTION }}">
{{ _('The maximum contribution amount is {0}.')|f(
settings.MAX_CONTRIBUTION|currencyfmt('USD')) }}
</div>
<div class="error" id="contrib-too-little">
{{ _('The minimum contribution amount is {0}.')|f(
0.01|currencyfmt('USD')) }}
</div>
<div class="error" id="contrib-not-entered">
{{ _('Contribution amount must be a number.') }}
</div>
<div class="error" id="paypal-error">
{{ _('There was an error communicating with paypal. Please try again later.') }}
</div>
<ul>
{% if has_suggested %}
<li>
<input type="radio" name="type" value="suggested"
id="contrib-suggested" checked="checked"/>
<label for="contrib-suggested">
{# L10n: {1} is a currency amount (e.g., $5.00) #}
{{ _('A one-time suggested contribution of {0}')|f(
addon.suggested_amount|currencyfmt('USD')) }}
</label>
</li>
{% endif %}
<li>
<input type="radio" name="type" value="onetime"
id="contrib-onetime"
{% if not has_suggested %}checked="checked"{% endif %}/>
<label>
{# L10n: {0} is a currency symbol (e.g., $),
{1} is an amount input field #}
{{ _('A one-time contribution of {0} {1}')|f(
'$', '<input type="text" name="onetime-amount" value=""/>')|safe }}
</label>
</li>
{% if not settings.PAYPAL_USE_EMBEDDED %}
<li>
<input type="radio" name="type" value="monthly"
id="contrib-monthly"/>
<label for="contrib-monthly">
{# L10n: {0} is a currency symbol (e.g., $),
{1} is an amount input field #}
{{ _('A regular monthly contribution of {0} {1}')|f(
'$', '</label><input type="text" name="monthly-amount" value=""/>')|safe }}
</li>
{% endif %}
</ul>

<h4 class="comment">
<label for="contrib-comment">
{{ _('Leave a comment or request with your contribution.') }}
</label>
</h4><span>{{ _('(optional)') }}</span>
<textarea name="comment" id="contrib-comment"></textarea>
<span class="commentlen"></span>

<button id="contribute-confirm" type="submit" class="prominent">
{{ _('Make Contribution') }}
</button>
<span class="cancel"><a href="#">{{ _('No Thanks') }}</a></span>
</form>
</div>{# /contribute-box #}



</div>{# /notification #}

<div class="hidden">
<div id="contribute-why" class="popup">
<p class="msg">
{% if addon.charity %}
{% if addon.charity_id == amo.FOUNDATION_ORG %}
{% 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 %}
The developer of this add-on would like you to consider making a
small contribution to <a href="{{ charity_url }}">{{ charity_name }}</a>
if you enjoy using it.
{% endtrans %}
{% endif %}
{% 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>

0 comments on commit 5dc1cfe

Please sign in to comment.