incorporate add_ask into campaign management

pull/1/head
eric 2014-08-30 12:04:50 -04:00
parent 73c616092d
commit 40831b6161
6 changed files with 27 additions and 7 deletions

View File

@ -8,13 +8,20 @@ from django.db import models
class Migration(SchemaMigration): class Migration(SchemaMigration):
def forwards(self, orm): def forwards(self, orm):
# Adding field 'Campaign.use_add_ask'
db.add_column('core_campaign', 'use_add_ask',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Adding field 'EbookFile.asking' # Adding field 'EbookFile.asking'
db.add_column('core_ebookfile', 'asking', db.add_column('core_ebookfile', 'asking',
self.gf('django.db.models.fields.BooleanField')(default=False), self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False) keep_default=False)
def backwards(self, orm): def backwards(self, orm):
# Deleting field 'Campaign.use_add_ask'
db.delete_column('core_campaign', 'use_add_ask')
# Deleting field 'EbookFile.asking' # Deleting field 'EbookFile.asking'
db.delete_column('core_ebookfile', 'asking') db.delete_column('core_ebookfile', 'asking')
@ -75,7 +82,7 @@ class Migration(SchemaMigration):
'license': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}), 'license': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'nonce': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}), 'nonce': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True'}),
'refreshed': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'refreshed': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'refreshes': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 25, 0, 0)', 'auto_now_add': 'True', 'blank': 'True'}), 'refreshes': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 28, 0, 0)', 'auto_now_add': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'acqs'", 'to': "orm['auth.User']"}), 'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'acqs'", 'to': "orm['auth.User']"}),
'watermarked': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['booxtream.Boox']", 'null': 'True'}), 'watermarked': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['booxtream.Boox']", 'null': 'True'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'acqs'", 'to': "orm['core.Work']"}) 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'acqs'", 'to': "orm['core.Work']"})
@ -116,6 +123,7 @@ class Migration(SchemaMigration):
'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': 'True', 'db_index': 'True'}), 'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': 'True', 'db_index': 'True'}),
'target': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'null': 'True', 'max_digits': '14', 'decimal_places': '2'}), 'target': ('django.db.models.fields.DecimalField', [], {'default': '0.0', 'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
'type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}), 'type': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'use_add_ask': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"}) 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
}, },
'core.campaignaction': { 'core.campaignaction': {
@ -129,7 +137,7 @@ class Migration(SchemaMigration):
'core.celerytask': { 'core.celerytask': {
'Meta': {'object_name': 'CeleryTask'}, 'Meta': {'object_name': 'CeleryTask'},
'active': ('django.db.models.fields.NullBooleanField', [], {'default': 'True', 'null': 'True', 'blank': 'True'}), 'active': ('django.db.models.fields.NullBooleanField', [], {'default': 'True', 'null': 'True', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 25, 0, 0)', 'auto_now_add': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2014, 8, 28, 0, 0)', 'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True'}), 'description': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True'}),
'function_args': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), 'function_args': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
'function_name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), 'function_name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),

View File

@ -401,6 +401,7 @@ class Campaign(models.Model):
email = models.CharField(max_length=100, blank=True) email = models.CharField(max_length=100, blank=True)
publisher = models.ForeignKey("Publisher", related_name="campaigns", null=True) publisher = models.ForeignKey("Publisher", related_name="campaigns", null=True)
do_watermark = models.BooleanField(default=True) do_watermark = models.BooleanField(default=True)
use_add_ask = models.BooleanField(default=True)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.problems=[] self.problems=[]

View File

@ -127,6 +127,10 @@ def notify_ending_soon():
def watermark_acq(acq): def watermark_acq(acq):
acq.get_watermarked() acq.get_watermarked()
@task
def add_ask_to_ebfs(campaign):
campaign.add_ask_to_ebfs()
@task @task
def refresh_acqs(): def refresh_acqs():
in_10_min = now() + timedelta(minutes=10) in_10_min = now() + timedelta(minutes=10)

View File

@ -478,7 +478,7 @@ def getManageCampaignForm ( instance, data=None, initial=None, *args, **kwargs )
class Meta: class Meta:
model = Campaign model = Campaign
fields = 'description', 'details', 'license', 'target', 'deadline', 'paypal_receiver', 'edition', 'email', 'publisher', 'cc_date_initial', "do_watermark" fields = 'description', 'details', 'license', 'target', 'deadline', 'paypal_receiver', 'edition', 'email', 'publisher', 'cc_date_initial', "do_watermark", "use_add_ask",
widgets = { 'deadline': SelectDateWidget } widgets = { 'deadline': SelectDateWidget }
def clean_target(self): def clean_target(self):

View File

@ -157,7 +157,7 @@ Please fix the following before launching your campaign:
<h3>Uploaded Files</h3> <h3>Uploaded Files</h3>
{% endif %} {% endif %}
{% if campaign.work.epubfiles.0 %} {% if campaign.work.epubfiles.0 %}
<p>Active EPUB file: <a href="{{campaign.work.epubfiles.0.file.url}}">{{campaign.work.epubfiles.0.file}}</a> <br />created {{campaign.work.epubfiles.0.created}} for edition <a href="#edition_{{campaign.work.epubfiles.0.edition.id}}">{{campaign.work.epubfiles.0.edition.id}}</a> </p> <p>Active EPUB file: <a href="{{campaign.work.epubfiles.0.file.url}}">{{campaign.work.epubfiles.0.file}}</a> <br />created {{campaign.work.epubfiles.0.created}} for edition <a href="#edition_{{campaign.work.epubfiles.0.edition.id}}">{{campaign.work.epubfiles.0.edition.id}}</a> {% if campaign.work.epubfiles.0.asking %}(This file has had the campaign 'ask' added.){% endif %}</p>
{% if campaign.work.test_acqs.0 %} {% if campaign.work.test_acqs.0 %}
<ul> <ul>
<li><a href="{{campaign.work.test_acqs.0.watermarked.download_link_epub}}">Processed epub for testing</a></li> <li><a href="{{campaign.work.test_acqs.0.watermarked.download_link_epub}}">Processed epub for testing</a></li>
@ -166,10 +166,10 @@ Please fix the following before launching your campaign:
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if campaign.work.mobifiles.0 %} {% if campaign.work.mobifiles.0 %}
<p>Active MOBI file: <a href="{{campaign.work.mobifiles.0.file.url}}">{{campaign.work.mobifiles.0.file}}</a> <br />created {{campaign.work.mobifiles.0.created}} for edition <a href="#edition_{{campaign.work.mobifiles.0.edition.id}}">{{campaign.work.mobifiles.0.edition.id}}</a> </p> <p>Active MOBI file: <a href="{{campaign.work.mobifiles.0.file.url}}">{{campaign.work.mobifiles.0.file}}</a> <br />created {{campaign.work.mobifiles.0.created}} for edition <a href="#edition_{{campaign.work.mobifiles.0.edition.id}}">{{campaign.work.mobifiles.0.edition.id}}</a> {% if campaign.work.mobifiles.0.asking %}(This file has had the campaign 'ask' added.){% endif %}</p>
{% endif %} {% endif %}
{% if campaign.work.pdffiles.0 %} {% if campaign.work.pdffiles.0 %}
<p>Active PDF file: <a href="{{campaign.work.pdffiles.0.file.url}}">{{campaign.work.pdffiles.0.file}}</a> <br />created {{campaign.work.pdffiles.0.created}} for edition <a href="#edition_{{campaign.work.pdffiles.0.edition.id}}">{{campaign.work.pdffiles.0.edition.id}}</a> </p> <p>Active PDF file: <a href="{{campaign.work.pdffiles.0.file.url}}">{{campaign.work.pdffiles.0.file}}</a> <br />created {{campaign.work.pdffiles.0.created}} for edition <a href="#edition_{{campaign.work.pdffiles.0.edition.id}}">{{campaign.work.pdffiles.0.edition.id}}</a> {% if campaign.work.pdffiles.0.asking %}(This file has had the campaign 'ask' added.){% endif %}</p>
{% endif %} {% endif %}
{% ifnotequal campaign_status 'ACTIVE' %} {% ifnotequal campaign_status 'ACTIVE' %}
{% ifnotequal campaign.type 3 %} {% ifnotequal campaign.type 3 %}
@ -318,6 +318,12 @@ Please fix the following before launching your campaign:
<div style="padding-top:2em;padding-bottom:0.5em">Next, the <b>Ask</b>. A "thank you" form will float right in this area, so don't use wide graphic elements.</div> <div style="padding-top:2em;padding-bottom:0.5em">Next, the <b>Ask</b>. A "thank you" form will float right in this area, so don't use wide graphic elements.</div>
{% endifequal %} {% endifequal %}
{{ form.description.errors }}{{ form.description }} {{ form.description.errors }}{{ form.description }}
{% ifequal campaign.type 3 %}
<h3>Enable "Thanks" in your ebook files</h3>
<p> Unglue.it can add your "Ask" along with a link to your book's "thank the creators" page into your ebook files. That way, people who download the book without making a contribution will be reminded that they can do it later.</p>
<div class="std_form">Add your ask to files: {{ form.use_add_ask.errors }}{{ form.use_add_ask }}</div>
{% endifequal %}
<h3>Edition and Rights Details</h3> <h3>Edition and Rights Details</h3>
<p>This will be displayed on the More... tab for your work. It's the fine print for your campaign. {% ifequal campaign.type 1 %}Make sure to disclose any ways the unglued edition will differ from the existing edition; for example: <p>This will be displayed on the More... tab for your work. It's the fine print for your campaign. {% ifequal campaign.type 1 %}Make sure to disclose any ways the unglued edition will differ from the existing edition; for example:
<ul class="bullets"> <ul class="bullets">

View File

@ -685,6 +685,7 @@ def manage_campaign(request, id, action='manage'):
campaign.update_left() campaign.update_left()
if campaign.type is THANKS : if campaign.type is THANKS :
campaign.work.description = form.cleaned_data['work_description'] campaign.work.description = form.cleaned_data['work_description']
tasks.add_ask_to_ebfs.delay(campaign)
campaign.work.save() campaign.work.save()
alerts.append(_('Campaign data has been saved')) alerts.append(_('Campaign data has been saved'))
activetab = '#2' activetab = '#2'