From 40831b6161d6924199f095c6d026459a2d1dd4ac Mon Sep 17 00:00:00 2001 From: eric Date: Sat, 30 Aug 2014 12:04:50 -0400 Subject: [PATCH] incorporate add_ask into campaign management --- ...ign_use_add_ask__add_field_ebookfile_asking.py} | 14 +++++++++++--- core/models.py | 1 + core/tasks.py | 4 ++++ frontend/forms.py | 2 +- frontend/templates/manage_campaign.html | 12 +++++++++--- frontend/views.py | 1 + 6 files changed, 27 insertions(+), 7 deletions(-) rename core/migrations/{0063_auto__add_field_ebookfile_asking.py => 0063_auto__add_field_campaign_use_add_ask__add_field_ebookfile_asking.py} (97%) diff --git a/core/migrations/0063_auto__add_field_ebookfile_asking.py b/core/migrations/0063_auto__add_field_campaign_use_add_ask__add_field_ebookfile_asking.py similarity index 97% rename from core/migrations/0063_auto__add_field_ebookfile_asking.py rename to core/migrations/0063_auto__add_field_campaign_use_add_ask__add_field_ebookfile_asking.py index cd842721..8a44c361 100644 --- a/core/migrations/0063_auto__add_field_ebookfile_asking.py +++ b/core/migrations/0063_auto__add_field_campaign_use_add_ask__add_field_ebookfile_asking.py @@ -8,13 +8,20 @@ from django.db import models class Migration(SchemaMigration): 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' db.add_column('core_ebookfile', 'asking', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): + # Deleting field 'Campaign.use_add_ask' + db.delete_column('core_campaign', 'use_add_ask') + # Deleting field 'EbookFile.asking' db.delete_column('core_ebookfile', 'asking') @@ -75,7 +82,7 @@ class Migration(SchemaMigration): 'license': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}), 'nonce': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': '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']"}), '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']"}) @@ -116,6 +123,7 @@ class Migration(SchemaMigration): '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'}), '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']"}) }, 'core.campaignaction': { @@ -129,7 +137,7 @@ class Migration(SchemaMigration): 'core.celerytask': { 'Meta': {'object_name': 'CeleryTask'}, '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'}), 'function_args': ('django.db.models.fields.IntegerField', [], {'null': 'True'}), 'function_name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}), diff --git a/core/models.py b/core/models.py index d1ba47cf..c894b6ea 100755 --- a/core/models.py +++ b/core/models.py @@ -401,6 +401,7 @@ class Campaign(models.Model): email = models.CharField(max_length=100, blank=True) publisher = models.ForeignKey("Publisher", related_name="campaigns", null=True) do_watermark = models.BooleanField(default=True) + use_add_ask = models.BooleanField(default=True) def __init__(self, *args, **kwargs): self.problems=[] diff --git a/core/tasks.py b/core/tasks.py index 01624670..258f2c4c 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -127,6 +127,10 @@ def notify_ending_soon(): def watermark_acq(acq): acq.get_watermarked() +@task +def add_ask_to_ebfs(campaign): + campaign.add_ask_to_ebfs() + @task def refresh_acqs(): in_10_min = now() + timedelta(minutes=10) diff --git a/frontend/forms.py b/frontend/forms.py index 277e4a53..f4b70be2 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -478,7 +478,7 @@ def getManageCampaignForm ( instance, data=None, initial=None, *args, **kwargs ) class Meta: 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 } def clean_target(self): diff --git a/frontend/templates/manage_campaign.html b/frontend/templates/manage_campaign.html index 1594c8ae..58740ec5 100644 --- a/frontend/templates/manage_campaign.html +++ b/frontend/templates/manage_campaign.html @@ -157,7 +157,7 @@ Please fix the following before launching your campaign:

Uploaded Files

{% endif %} {% if campaign.work.epubfiles.0 %} -

Active EPUB file: {{campaign.work.epubfiles.0.file}}
created {{campaign.work.epubfiles.0.created}} for edition {{campaign.work.epubfiles.0.edition.id}}

+

Active EPUB file: {{campaign.work.epubfiles.0.file}}
created {{campaign.work.epubfiles.0.created}} for edition {{campaign.work.epubfiles.0.edition.id}} {% if campaign.work.epubfiles.0.asking %}(This file has had the campaign 'ask' added.){% endif %}

{% if campaign.work.test_acqs.0 %}