remove assumption that successful campaign is last

pull/1/head
eric 2016-04-25 14:56:17 -04:00
parent c74500e9d7
commit 20102ffc12
1 changed files with 4 additions and 2 deletions

View File

@ -3064,8 +3064,10 @@ def download_purchased(request, work_id):
def download_campaign(request, work_id, format): def download_campaign(request, work_id, format):
work = safe_get_work(work_id) work = safe_get_work(work_id)
campaign = work.last_campaign() campaign = None
if campaign is None or (campaign.status != 'SUCCESSFUL'): for campaign in work.campaigns.filter(status='SUCCESSFUL'):
continue
if not campaign:
raise Http404 raise Http404
if campaign.type is BUY2UNGLUE: if campaign.type is BUY2UNGLUE:
ebfs= models.EbookFile.objects.filter(edition__work=campaign.work, format=format).exclude(file='').order_by('-created') ebfs= models.EbookFile.objects.filter(edition__work=campaign.work, format=format).exclude(file='').order_by('-created')