no contrib form if the ask is all zero

pull/1/head
eric 2014-07-25 14:43:54 -04:00
parent 88b292afaf
commit aa84366418
4 changed files with 45 additions and 18 deletions

View File

@ -809,6 +809,19 @@ class Campaign(models.Model):
except Offer.DoesNotExist: except Offer.DoesNotExist:
return None return None
@property
def ask_money(self):
# true if there's an offer asking for money
if self.type is REWARDS:
return True
try:
Offer.objects.get(work=self.work, active=True, price__gt=0.00)
return True
except Offer.DoesNotExist:
return False
except Offer.MultipleObjectsReturned:
return True
@property @property
def days_per_copy(self): def days_per_copy(self):
if self.individual_offer: if self.individual_offer:

View File

@ -23,25 +23,32 @@ $j(document).ready(function() {
<div id="lightbox_content"> <div id="lightbox_content">
<span id="dropboxjs" data-app-key="{{ dropbox_key }}"></span> <span id="dropboxjs" data-app-key="{{ dropbox_key }}"></span>
{% if show_beg %} {% if show_beg %}
<div class="border" style="padding: 10px; min-height: 18em"> {% if work.last_campaign.ask_money %}
<div id="askblock"> <div class="border" style="padding: 10px; min-height: 18em">
<div>Please help us thank the creators for making this book free. The amount is up to you.</div> <div id="askblock">
<form class="askform" method="POST" action="{% url thank work.id %}#"> <div>Please help us thank the creators for making this book free. The amount is up to you.</div>
{% csrf_token %} <form class="askform" method="POST" action="{% url thank work.id %}#">
{{ form.non_field_errors }} {% csrf_token %}
<div class="contrib_amount">Amount: {{ form.preapproval_amount.errors }}${{ form.preapproval_amount }}</div> {{ form.non_field_errors }}
<div style="text-align: center;"><input name="pledge" type="submit" value="Say Thank You" id="contribsubmit" class="loader-gif" /></div> <div class="contrib_amount">Amount: {{ form.preapproval_amount.errors }}${{ form.preapproval_amount }}</div>
<div id="anoncontribbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div> <div style="text-align: center;"><input name="pledge" type="submit" value="Say Thank You" id="contribsubmit" class="loader-gif" /></div>
{% if request.user.credit.available > 0 %} <div id="anoncontribbox"><I>{{ form.anonymous.label_tag }}</I> {{ form.anonymous.errors }}{{ form.anonymous }}</div>
<div > You have an available credit of ${{ request.user.credit.available|intcomma }} which will be applied to your contribution.</div> {% if request.user.credit.available > 0 %}
{% endif %} <div > You have an available credit of ${{ request.user.credit.available|intcomma }} which will be applied to your contribution.</div>
</form> {% endif %}
</form>
</div>
<div class="rh_ask">
{{ work.last_campaign.description|safe }}
</div>
</div> </div>
{% else %}
<div class="rh_ask"> <div class="border" style="padding: 10px">
{{ work.last_campaign.description|safe }} <div class="rh_ask">
{{ work.last_campaign.description|safe }}
</div>
</div> </div>
</div> {% endif %}
{% endif %} {% endif %}
{% if user_license.thanked %} {% if user_license.thanked %}
<div style="text-align: center; padding: 20px;"> <div style="text-align: center; padding: 20px;">

View File

@ -451,7 +451,7 @@ Please fix the following before launching your campaign:
{% if not campaign.work.ebookfiles.0 %} {% if not campaign.work.ebookfiles.0 %}
<p> <b>ebook files for this work <a class="tabs1">need to be loaded</a>!</b></p> <p> <b>ebook files for this work <a class="tabs1">need to be loaded</a>!</b></p>
{% endif %} {% endif %}
<p> Enter a suggested per/copy contribution for each user type. You may change these numbers after the campaign has begun. Don't suggest contributions between $0.00 and $1.00, because these won't be processed.</p> <p> Enter a suggested per/copy contribution for each user type. You may change these numbers after the campaign has begun. Don't suggest contributions between $0.00 and $1.00, because these won't be processed. If you enter $0 for BOTH, then no contribution form will be displayed.</p>
<div class="jsmod-content"> <div class="jsmod-content">
{% for offer in offers %} {% for offer in offers %}
<form action="#" method="POST"><div> <form action="#" method="POST"><div>

View File

@ -690,6 +690,7 @@
<span class="menu-item-desc">You're welcome!</span> <span class="menu-item-desc">You're welcome!</span>
</li> </li>
{% else %} {% else %}
{% if work.last_campaign.ask_money %}
<li class="first last" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <li class="first last" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
{% if request.user.library %} {% if request.user.library %}
<a href="{% url thank work_id %}?offer_id={{work.last_campaign.library_offer.id}}"> <a href="{% url thank work_id %}?offer_id={{work.last_campaign.library_offer.id}}">
@ -703,6 +704,12 @@
</a> </a>
{% endif %} {% endif %}
</li> </li>
{% else %}
<li class="first last" >
<a href="{% url download work_id %}">
<span class="menu-item-desc">Just read the book!</span>
</a>
{% endif %}
{% endif %} {% endif %}
</ul> </ul>
</div> </div>