make sure the campaigns for the editions returned by editions_to_convert are not b2u.

pull/1/head
Raymond Yee 2015-02-02 15:05:36 -08:00
parent a2f478312e
commit edd65c08c3
2 changed files with 52 additions and 2 deletions

View File

@ -12,6 +12,7 @@ from django.core.files.storage import default_storage
from django.core.files.base import ContentFile, File
from regluit.core.models import (Campaign, Ebook)
from regluit.core import parameters
def convert_to_mobi(input_url, input_format="application/epub+zip"):
@ -89,7 +90,8 @@ def write_file_to_storage(file_object, content_type, path):
def editions_to_convert():
for campaign in Campaign.objects.filter(edition__ebooks__isnull=False).distinct():
if edition_mobi_status(campaign.edition) == 0: # possible to generate mobi
# need to make sure campaign type is not B2U because kindlegen is for books we give awy free of charge
if (edition_mobi_status(campaign.edition) == 0) and (campaign.type != parameters.BUY2UNGLUE): # possible to generate mobi
yield campaign.edition

View File

@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:222732889664d1441c27da33432ee5bb01c23697dee8f1243574a573d3c77f99"
"signature": "sha256:2a1e6efa2c9f22f584f68cb52a282e34820d954023d8a8860c1f96979e2b4697"
},
"nbformat": 3,
"nbformat_minor": 0,
@ -24,6 +24,33 @@
"metadata": {},
"outputs": []
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Make sure the Campaigns are of the correct type given the licensing of kindlegen"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**I think T4U and pledge campaigns but not B2U.**"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from regluit.core.models import Campaign\n",
"from regluit.core import parameters\n",
"(parameters.REWARDS, parameters.BUY2UNGLUE, parameters.THANKS)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
@ -34,6 +61,27 @@
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"e = list(editions_to_convert())[0]\n",
"e.work.last_campaign().type"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"[edition.work.last_campaign().type for edition in editions_to_convert()]"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,