diff --git a/core/fixtures/initial_data.json b/core/fixtures/initial_data.json
index f2373fc9..a6c501aa 100644
--- a/core/fixtures/initial_data.json
+++ b/core/fixtures/initial_data.json
@@ -1,10 +1,50 @@
[
{
- "model": "sites.site",
- "pk": 1,
+ "pk": 1,
+ "model": "sites.site",
"fields": {
- "domain": "unglue.it",
+ "domain": "unglue.it",
"name": "unglue.it"
}
+ },
+ {
+ "pk": 1,
+ "model": "core.premium",
+ "fields": {
+ "campaign": null,
+ "amount": 1,
+ "type": "00",
+ "description": "The unglued ebook delivered to your inbox."
+ }
+ },
+ {
+ "pk": 2,
+ "model": "core.premium",
+ "fields": {
+ "campaign": null,
+ "amount": 25,
+ "type": "00",
+ "description": "Your name under \"supporters\" in the acknowledgements section."
+ }
+ },
+ {
+ "pk": 3,
+ "model": "core.premium",
+ "fields": {
+ "campaign": null,
+ "amount": 50,
+ "type": "00",
+ "description": "Your name and link of your choice under \"benefactors\""
+ }
+ },
+ {
+ "pk": 4,
+ "model": "core.premium",
+ "fields": {
+ "campaign": null,
+ "amount": 100,
+ "type": "00",
+ "description": "Your name, link of your choice, and a brief message (140 characters max) under \"bibliophiles\""
+ }
}
]
diff --git a/core/migrations/0007_auto__add_premium.py b/core/migrations/0007_auto__add_premium.py
new file mode 100644
index 00000000..2d96babb
--- /dev/null
+++ b/core/migrations/0007_auto__add_premium.py
@@ -0,0 +1,147 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Adding model 'Premium'
+ db.create_table('core_premium', (
+ ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+ ('type', self.gf('django.db.models.fields.CharField')(max_length=2)),
+ ('campaign', self.gf('django.db.models.fields.related.ForeignKey')(related_name='premiums', blank=True, to=orm['core.Campaign'])),
+ ('amount', self.gf('django.db.models.fields.DecimalField')(max_digits=10, decimal_places=0)),
+ ('description', self.gf('django.db.models.fields.TextField')(null=True)),
+ ))
+ db.send_create_signal('core', ['Premium'])
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Premium'
+ db.delete_table('core_premium')
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'core.author': {
+ 'Meta': {'object_name': 'Author'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authors'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'core.campaign': {
+ 'Meta': {'object_name': 'Campaign'},
+ 'activated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'amazon_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'deadline': ('django.db.models.fields.DateTimeField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
+ 'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'suspended': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'suspended_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
+ 'withdrawn': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'withdrawn_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
+ },
+ 'core.edition': {
+ 'Meta': {'object_name': 'Edition'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
+ 'googlebooks_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'isbn_10': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}),
+ 'isbn_13': ('django.db.models.fields.CharField', [], {'max_length': '13', 'null': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True'}),
+ 'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'publisher': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
+ 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.Work']"})
+ },
+ 'core.premium': {
+ 'Meta': {'object_name': 'Premium'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '0'}),
+ 'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'premiums'", 'blank': 'True', 'to': "orm['core.Campaign']"}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
+ },
+ 'core.subject': {
+ 'Meta': {'object_name': 'Subject'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subjects'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'core.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'goodreads_auth_secret': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'goodreads_auth_token': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_link': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'home_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'tagline': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
+ 'twitter_id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"})
+ },
+ 'core.wishlist': {
+ 'Meta': {'object_name': 'Wishlist'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'wishlist'", 'unique': 'True', 'to': "orm['auth.User']"}),
+ 'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'wishlists'", 'symmetrical': 'False', 'to': "orm['core.Work']"})
+ },
+ 'core.work': {
+ 'Meta': {'object_name': 'Work'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'openlibrary_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'})
+ }
+ }
+
+ complete_apps = ['core']
diff --git a/core/migrations/0008_auto__chg_field_premium_campaign.py b/core/migrations/0008_auto__chg_field_premium_campaign.py
new file mode 100644
index 00000000..9a3157bc
--- /dev/null
+++ b/core/migrations/0008_auto__chg_field_premium_campaign.py
@@ -0,0 +1,140 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+
+ # Changing field 'Premium.campaign'
+ db.alter_column('core_premium', 'campaign_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, to=orm['core.Campaign']))
+
+
+ def backwards(self, orm):
+
+ # Changing field 'Premium.campaign'
+ db.alter_column('core_premium', 'campaign_id', self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['core.Campaign']))
+
+
+ models = {
+ 'auth.group': {
+ 'Meta': {'object_name': 'Group'},
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+ 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+ },
+ 'auth.permission': {
+ 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+ 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+ },
+ 'auth.user': {
+ 'Meta': {'object_name': 'User'},
+ 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+ 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+ 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+ 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+ 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+ 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+ },
+ 'contenttypes.contenttype': {
+ 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+ 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+ },
+ 'core.author': {
+ 'Meta': {'object_name': 'Author'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'authors'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'core.campaign': {
+ 'Meta': {'object_name': 'Campaign'},
+ 'activated': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'amazon_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'deadline': ('django.db.models.fields.DateTimeField', [], {}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
+ 'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
+ 'suspended': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'suspended_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'target': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
+ 'withdrawn': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
+ 'withdrawn_reason': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
+ },
+ 'core.edition': {
+ 'Meta': {'object_name': 'Edition'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
+ 'googlebooks_id': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'isbn_10': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True'}),
+ 'isbn_13': ('django.db.models.fields.CharField', [], {'max_length': '13', 'null': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '2', 'null': 'True'}),
+ 'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+ 'publisher': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
+ 'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.Work']"})
+ },
+ 'core.premium': {
+ 'Meta': {'object_name': 'Premium'},
+ 'amount': ('django.db.models.fields.DecimalField', [], {'max_digits': '10', 'decimal_places': '0'}),
+ 'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'premiums'", 'null': 'True', 'to': "orm['core.Campaign']"}),
+ 'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
+ },
+ 'core.subject': {
+ 'Meta': {'object_name': 'Subject'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'editions': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subjects'", 'symmetrical': 'False', 'to': "orm['core.Edition']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ 'core.userprofile': {
+ 'Meta': {'object_name': 'UserProfile'},
+ 'goodreads_auth_secret': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'goodreads_auth_token': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_id': ('django.db.models.fields.CharField', [], {'max_length': '32', 'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_link': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'goodreads_user_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'home_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'tagline': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
+ 'twitter_id': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"})
+ },
+ 'core.wishlist': {
+ 'Meta': {'object_name': 'Wishlist'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'wishlist'", 'unique': 'True', 'to': "orm['auth.User']"}),
+ 'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'wishlists'", 'symmetrical': 'False', 'to': "orm['core.Work']"})
+ },
+ 'core.work': {
+ 'Meta': {'object_name': 'Work'},
+ 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'openlibrary_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'})
+ }
+ }
+
+ complete_apps = ['core']
diff --git a/core/models.py b/core/models.py
index 836c4979..6c5ad0bc 100755
--- a/core/models.py
+++ b/core/models.py
@@ -9,6 +9,13 @@ from django.contrib.auth.models import User
class UnglueitError(RuntimeError):
pass
+class Premium(models.Model):
+ PREMIUM_TYPES = ((u'00', u'Default'),(u'CU', u'Custom'))
+ type = models.CharField(max_length=2, choices=PREMIUM_TYPES)
+ campaign = models.ForeignKey("Campaign", related_name="premiums", null=True)
+ amount = models.DecimalField(max_digits=10, decimal_places=0, blank=False)
+ description = models.TextField(null=True, blank=False)
+
class Campaign(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=500, null=True, blank=False)
@@ -124,25 +131,34 @@ class Work(models.Model):
try:
last = self.campaigns.order_by('-created')[0]
except:
- last = "No campaign yet"
+ last = None
return last
+
+ def last_campaign_status(self):
+ campaign = self.last_campaign
+ if campaign:
+ status = campaign.status
+ else:
+ status = "No campaign yet"
+ return status
def percent_unglued(self):
- if(self.last_campaign().status == 'SUCCESSFUL'):
- return 6;
- elif(self.last_campaign().status == 'ACTIVE'):
- target = float(self.campaigns.order_by('-created')[0].target)
- if target <= 0:
- return 6
- else:
- total = float(self.campaigns.order_by('-created')[0].current_total)
- percent = int(total*6/target)
- if percent >= 6:
- return 6
+ status = 0
+ if last_campaign is not None:
+ if(self.last_campaign().status == 'SUCCESSFUL'):
+ status = 6;
+ elif(self.last_campaign().status == 'ACTIVE'):
+ target = float(self.campaigns.order_by('-created')[0].target)
+ if target <= 0:
+ status = 6
else:
- return percent;
- else:
- return 0;
+ total = float(self.campaigns.order_by('-created')[0].current_total)
+ percent = int(total*6/target)
+ if percent >= 6:
+ status = 6
+ else:
+ status = percent;
+ return status;
def __unicode__(self):
return self.title
diff --git a/frontend/templates/supporter.html b/frontend/templates/supporter.html
index a14fb365..5b0a12c3 100644
--- a/frontend/templates/supporter.html
+++ b/frontend/templates/supporter.html
@@ -233,10 +233,10 @@ how do I integrate the your wishlist thing with the tabs thing?
{% endifequal %}
{% else %}
{% for work in wishlist.works.all %}
-
- {% if work.last_campaign.status == 'SUCCESSFUL' %}
+
+ {% if work.last_campaign_status == 'SUCCESSFUL' %}
- {% else %}{% if work.last_campaign.status == 'ACTIVE' %}
+ {% else %}{% if work.last_campaign_status == 'ACTIVE' %}
{% else %}
@@ -268,7 +268,7 @@ how do I integrate the your wishlist thing with the tabs thing?
{% endif %}{% endif %}{% endifequal %}
-
{{ work.last_campaign.status }}
+
{{ work.last_campaign_status }}
diff --git a/frontend/templates/supporter_panel.html b/frontend/templates/supporter_panel.html
index 5d14dd4e..0f3ce397 100644
--- a/frontend/templates/supporter_panel.html
+++ b/frontend/templates/supporter_panel.html
@@ -236,10 +236,10 @@ how to handle overlong author/titles? Am using truncatewords; truncatechars is b
{% else %}
{% for work in wishlist.works.all %}
-
- {% if work.last_campaign.status == 'SUCCESSFUL' %}
+
+ {% if work.last_campaign_status == 'SUCCESSFUL' %}
- {% else %}{% if work.last_campaign.status == 'ACTIVE' %}
+ {% else %}{% if work.last_campaign_status == 'ACTIVE' %}
{% else %}
@@ -250,7 +250,7 @@ how to handle overlong author/titles? Am using truncatewords; truncatechars is b
{{ work.title|truncatewords:5 }}
{{ work.author|truncatewords:3 }}
-
Status: {{ work.last_campaign.status }}
+
Status: {{ work.last_campaign_status }}
100%
@@ -284,7 +284,7 @@ how to handle overlong author/titles? Am using truncatewords; truncatechars is b
{{ work.title }}
{{ work.author }}
-
Status: {{ work.last_campaign.status }}
+
Status: {{ work.last_campaign_status }}
diff --git a/settings/common.py b/settings/common.py
index ecf9868d..a4d257a1 100644
--- a/settings/common.py
+++ b/settings/common.py
@@ -184,5 +184,8 @@ SOUTH_TESTS_MIGRATE = True
AUTH_PROFILE_MODULE = "core.userprofile"
+GOODREADS_API_KEY = ""
+GOODREADS_API_SECRET = ""
+
import djcelery
djcelery.setup_loader()