fix send_to_kindle

pull/1/head
eric 2014-05-05 12:21:59 -04:00
parent 935c7b4a4c
commit da7d6ccfc5
1 changed files with 14 additions and 5 deletions

View File

@ -2929,11 +2929,20 @@ def send_to_kindle(request, work_id, javascript='0'):
work=safe_get_work(work_id) work=safe_get_work(work_id)
context= {'work':work} context= {'work':work}
acq = None acq = None
if request.user.is_authenticated(): if request.user.is_authenticated():
try: all_acqs=request.user.acqs.filter(work=work).order_by('-created')
acq = request.user.acqs.filter(work=work).order_by('-created')[0] for an_acq in all_acqs:
except IndexError: if not an_acq.expired:
acq = None # skip for THANKS
if an_acq.license == THANKED:
acq = None
break
# prepare this acq for download
if not an_acq.watermarked or an_acq.watermarked.expired:
if not an_acq.on_reserve:
watermark_acq.delay(an_acq)
acq = an_acq
break
if acq: if acq:
ebook_url = acq.get_mobi_url() ebook_url = acq.get_mobi_url()