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,7 +23,8 @@ $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 class="border" style="padding: 10px; min-height: 18em">
<div id="askblock"> <div id="askblock">
<div>Please help us thank the creators for making this book free. The amount is up to you.</div> <div>Please help us thank the creators for making this book free. The amount is up to you.</div>
<form class="askform" method="POST" action="{% url thank work.id %}#"> <form class="askform" method="POST" action="{% url thank work.id %}#">
@ -37,11 +38,17 @@ $j(document).ready(function() {
{% endif %} {% endif %}
</form> </form>
</div> </div>
<div class="rh_ask"> <div class="rh_ask">
{{ work.last_campaign.description|safe }} {{ work.last_campaign.description|safe }}
</div> </div>
</div> </div>
{% else %}
<div class="border" style="padding: 10px">
<div class="rh_ask">
{{ work.last_campaign.description|safe }}
</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>