if library supports t4u book, members of library don't see the ask

instead they see “your library has supported this free ebook!
pull/1/head
eric 2014-03-18 22:30:21 -04:00
parent 7bcc7cd409
commit 5661377207
5 changed files with 27 additions and 1 deletions

View File

@ -1346,6 +1346,14 @@ class Work(models.Model):
return True
return False
def lib_thanked(self, user):
if user.is_anonymous():
return False
lib_license=self.get_lib_license(user)
if lib_license and lib_license.thanked:
return True
return False
def in_library(self,user):
if user.is_anonymous():
return False
@ -1412,6 +1420,10 @@ class Work(models.Model):
def borrowable(self):
return self.acqs.filter(license=LIBRARY, refreshes__lt=now()).count()>0
@property
def thanked(self):
return self.acqs.filter(license=THANKED).count()>0
@property
def borrowable_acq(self):
for acq in self.acqs.filter(license=LIBRARY, refreshes__lt=now()):

View File

@ -90,9 +90,11 @@
{% if in_library %}
{% if borrowable %}
<p>Available in your library now!</p>
{% else %}{% if lib_thanked %}
<p>Supported by your library!</p>
{% else %}
<p>Available in your library on<br />{{ next_acq.refreshes|date:"M j, Y" }}</p>
{% endif %}
{% endif %}{% endif %}
{% else %}
{% ifequal work.last_campaign.type 1 %}
<b>UNGLUE IT!</b>

View File

@ -50,6 +50,13 @@ $j(document).ready(function() {
</div>
</div>
{% endif %}
{% if lib_thanked %}
<div style="text-align: center; padding: 20px;">
<div style="background: #edf3f4; padding: 10px; width:35%; display: inline; ">
Your library has supported this free book!
</div>
</div>
{% endif %}
{% if amount %}
<div style="text-align: center; padding: 20px;">
<div style="background: #edf3f4; padding: 10px; width:35%; display: inline; ">

View File

@ -15,6 +15,7 @@ def purchased(context):
user_license = work.get_user_license(user)
context['borrowable'] = work.borrowable(user)
context['in_library'] = work.in_library(user)
context['lib_thanked'] = work.lib_thanked(user)
except AttributeError:
user_license = None
context['borrowable'] = None

View File

@ -2618,6 +2618,8 @@ class DownloadView(PurchaseView):
return False
elif self.user_license and self.user_license.thanked:
return self.request.REQUEST.has_key('offer_id')
elif self.lib_thanked:
return False
elif self.campaign.status != 'ACTIVE':
return self.request.REQUEST.has_key('testmode')
else:
@ -2646,6 +2648,7 @@ class DownloadView(PurchaseView):
self.work = safe_get_work(self.kwargs["work_id"])
self.campaign = self.work.last_campaign()
self.user_license = self.work.get_user_license(self.request.user)
self.lib_thanked = self.work.lib_thanked(self.request.user)
self.data = {
'preapproval_amount':self.get_preapproval_amount(),
'anonymous':True if self.request.user.is_anonymous() else self.request.user.profile.anon_pref,
@ -2739,6 +2742,7 @@ class DownloadView(PurchaseView):
'site': site,
'action': "Contribution",
'user_license': self.user_license,
'lib_thanked': self.lib_thanked,
'amount': self.request.session.pop('amount') if self.request.session.has_key('amount') else None,
})
return context