Merge branch 'master' of github.com:Gluejar/regluit into payment

pull/1/head
Raymond Yee 2011-12-10 14:16:19 -08:00
commit 1abc445c44
16 changed files with 702 additions and 245 deletions

View File

@ -83,7 +83,7 @@ class ApiTests(TestCase):
self.assertEqual(j['objects'][0]['in_wishlist'], False) self.assertEqual(j['objects'][0]['in_wishlist'], False)
w = models.Work.objects.get(editions__isbn_10='0441012035') w = models.Work.objects.get(editions__isbn_10='0441012035')
self.user.wishlist.works.add(w) self.user.wishlist.add_work(w,'test')
r = self.client.get('/api/v1/campaign/', data={ r = self.client.get('/api/v1/campaign/', data={
'format': 'json', 'format': 'json',
'work__editions__isbn_10': '0441012035', 'work__editions__isbn_10': '0441012035',

View File

@ -171,8 +171,9 @@ def merge_works(w1, w2):
campaign.work = w1 campaign.work = w1
campaign.save() campaign.save()
for wishlist in models.Wishlist.objects.filter(works__in=[w2]): for wishlist in models.Wishlist.objects.filter(works__in=[w2]):
wishlist.works.remove(w2) w2source=wishlist.work_source(w2)
wishlist.works.add(w1) wishlist.remove_work(w2)
wishlist.add_work(w1, w2source)
w2.delete() w2.delete()

View File

@ -290,7 +290,7 @@ def load_goodreads_shelf_into_wishlist(user, shelf_name='all', goodreads_user_id
# let's not trigger too much traffic to Google books for now # let's not trigger too much traffic to Google books for now
# regluit.core.tasks.add_related.delay(isbn) # regluit.core.tasks.add_related.delay(isbn)
user.wishlist.works.add(edition.work) user.wishlist.add_work(edition.work, 'goodreads')
logger.info("Work with isbn %s added to wishlist.", isbn) logger.info("Work with isbn %s added to wishlist.", isbn)
except Exception, e: except Exception, e:
logger.info ("Exception adding ISBN %s: %s", isbn, e) logger.info ("Exception adding ISBN %s: %s", isbn, e)

View File

@ -219,7 +219,7 @@ def load_librarything_into_wishlist(user, lt_username, max_books=None):
# let's not trigger too much traffic to Google books for now # let's not trigger too much traffic to Google books for now
# regluit.core.tasks.add_related.delay(isbn) # regluit.core.tasks.add_related.delay(isbn)
user.wishlist.works.add(edition.work) user.wishlist.add_work(edition.work, 'librarything')
logger.info("Work with isbn %s added to wishlist.", isbn) logger.info("Work with isbn %s added to wishlist.", isbn)
except Exception, e: except Exception, e:
logger.info ("error adding ISBN %s: %s", isbn, e) logger.info ("error adding ISBN %s: %s", isbn, e)

View File

@ -14,7 +14,7 @@ class Command(BaseCommand):
continue continue
for work in Work.objects.all(): for work in Work.objects.all():
print "adding %s to %s's wishlist" % (work, user) print "adding %s to %s's wishlist" % (work, user)
user.wishlist.works.add(work) user.wishlist.add_work(work, 'random')
except Exception, e: except Exception, e:
print e print e
pass pass

View File

@ -0,0 +1,193 @@
# 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):
pass
def backwards(self, orm):
pass
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'}),
'details': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'managers': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'campaigns'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': '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.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(2011, 12, 8, 9, 12, 15, 273108)', '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'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'task_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tasks'", 'null': 'True', 'to': "orm['auth.User']"})
},
'core.claim': {
'Meta': {'object_name': 'Claim'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'rights_holder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.RightsHolder']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '7'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['auth.User']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.Work']"})
},
'core.ebook': {
'Meta': {'object_name': 'Ebook'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ebooks'", 'to': "orm['core.Edition']"}),
'format': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'rights': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
},
'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'}),
'goodreads_id': ('django.db.models.fields.CharField', [], {'max_length': '50', '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'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'oclc': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True'}),
'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': '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']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'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.rightsholder': {
'Meta': {'object_name': 'RightsHolder'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'rights_holder'", 'to': "orm['auth.User']"}),
'rights_holder_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
},
'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'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'facebook_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'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'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '31', 'blank': 'True'}),
'pic_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': '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.wishes': {
'Meta': {'object_name': 'Wishes', 'db_table': "'core_wishlist_works'"},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'wishlist': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Wishlist']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Work']"})
},
'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', 'through': "orm['core.Wishes']", 'to': "orm['core.Work']"})
},
'core.work': {
'Meta': {'ordering': "['title']", 'object_name': 'Work'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': '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']

View File

@ -0,0 +1,207 @@
# 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 field 'Wishes.created'
db.add_column('core_wishlist_works', 'created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, default=datetime.date(2011, 12, 8), blank=True), keep_default=False)
# Adding field 'Wishes.source'
db.add_column('core_wishlist_works', 'source', self.gf('django.db.models.fields.CharField')(default='', max_length=15, blank=True), keep_default=False)
def backwards(self, orm):
# Deleting field 'Wishes.created'
db.delete_column('core_wishlist_works', 'created')
# Deleting field 'Wishes.source'
db.delete_column('core_wishlist_works', 'source')
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'}),
'details': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'managers': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'campaigns'", 'symmetrical': 'False', 'to': "orm['auth.User']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True'}),
'paypal_receiver': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': '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.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(2011, 12, 8, 15, 46, 54, 337715)', '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'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'task_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'tasks'", 'null': 'True', 'to': "orm['auth.User']"})
},
'core.claim': {
'Meta': {'object_name': 'Claim'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'rights_holder': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.RightsHolder']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'pending'", 'max_length': '7'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['auth.User']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'claim'", 'to': "orm['core.Work']"})
},
'core.ebook': {
'Meta': {'object_name': 'Ebook'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ebooks'", 'to': "orm['core.Edition']"}),
'format': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'provider': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'rights': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '1024'})
},
'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'}),
'goodreads_id': ('django.db.models.fields.CharField', [], {'max_length': '50', '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'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'oclc': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True'}),
'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': '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']"}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'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.rightsholder': {
'Meta': {'object_name': 'RightsHolder'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'rights_holder'", 'to': "orm['auth.User']"}),
'rights_holder_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'})
},
'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'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'facebook_id': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True'}),
'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'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '31', 'blank': 'True'}),
'pic_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'blank': '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.wishes': {
'Meta': {'object_name': 'Wishes', 'db_table': "'core_wishlist_works'"},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '15', 'blank': 'True'}),
'wishlist': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Wishlist']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Work']"})
},
'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', 'through': "orm['core.Wishes']", 'to': "orm['core.Work']"})
},
'core.work': {
'Meta': {'ordering': "['title']", 'object_name': 'Work'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'librarything_id': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': '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']

View File

@ -406,10 +406,37 @@ class Ebook(models.Model):
class Wishlist(models.Model): class Wishlist(models.Model):
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
user = models.OneToOneField(User, related_name='wishlist') user = models.OneToOneField(User, related_name='wishlist')
works = models.ManyToManyField('Work', related_name='wishlists') works = models.ManyToManyField('Work', related_name='wishlists', through='Wishes')
def __unicode__(self): def __unicode__(self):
return "%s's Wishlist" % self.user.username return "%s's Wishlist" % self.user.username
def add_work(self, work, source):
try:
w = Wishes.objects.get(wishlist=self,work=work)
w.source=source
except:
Wishes.objects.create(source=source,wishlist=self,work=work)
def remove_work(self, work):
w = Wishes.objects.filter(wishlist=self, work=work)
if w:
w.delete()
def work_source(self, work):
w = Wishes.objects.filter(wishlist=self, work=work)
if w:
return w[0].source
else:
return ''
class Wishes(models.Model):
created = models.DateTimeField(auto_now_add=True)
source = models.CharField(max_length=15, blank=True)
wishlist = models.ForeignKey('Wishlist')
work = models.ForeignKey('Work')
class Meta:
db_table = 'core_wishlist_works'
class UserProfile(models.Model): class UserProfile(models.Model):
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)

View File

@ -86,8 +86,8 @@ class TestBookLoader(TestCase):
# add the stub works to a wishlist # add the stub works to a wishlist
user = User.objects.create_user('test', 'test@example.com', 'testpass') user = User.objects.create_user('test', 'test@example.com', 'testpass')
user.wishlist.works.add(e1.work) user.wishlist.add_work(e1.work, 'test')
user.wishlist.works.add(e2.work) user.wishlist.add_work(e2.work, 'test')
# create campaigns for the stub works # create campaigns for the stub works
c1 = models.Campaign.objects.create( c1 = models.Campaign.objects.create(
@ -248,9 +248,9 @@ class WishlistTest(TestCase):
user = User.objects.create_user('test', 'test@example.com', 'testpass') user = User.objects.create_user('test', 'test@example.com', 'testpass')
edition = bookloader.add_by_isbn('0441012035') edition = bookloader.add_by_isbn('0441012035')
work = edition.work work = edition.work
user.wishlist.works.add(work) user.wishlist.add_work(work, 'test')
self.assertEqual(user.wishlist.works.count(), 1) self.assertEqual(user.wishlist.works.count(), 1)
user.wishlist.works.remove(work) user.wishlist.remove_work(work)
self.assertEqual(user.wishlist.works.count(), 0) self.assertEqual(user.wishlist.works.count(), 0)
class SettingsTest(TestCase): class SettingsTest(TestCase):

View File

@ -102,7 +102,7 @@ class MyZotero(Zotero2):
edition = bookloader.add_by_isbn(isbn) edition = bookloader.add_by_isbn(isbn)
# let's not trigger too much traffic to Google books for now # let's not trigger too much traffic to Google books for now
# regluit.core.tasks.add_related.delay(isbn) # regluit.core.tasks.add_related.delay(isbn)
user.wishlist.works.add(edition.work) user.wishlist.add_work(edition.work, 'zotero')
logger.info("Work with isbn %s added to wishlist.", isbn) logger.info("Work with isbn %s added to wishlist.", isbn)
except Exception, e: except Exception, e:
logger.info ("error adding ISBN %s: %s", isbn, e) logger.info ("error adding ISBN %s: %s", isbn, e)

View File

@ -1,222 +1,208 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block extra_css %} {% block extra_css %}
<link type="text/css" rel="stylesheet" href="/static/css/landingpage.css" /> <link type="text/css" rel="stylesheet" href="/static/css/landingpage.css" />
<link type="text/css" rel="stylesheet" href="/static/css/book_panel.css" /> <link type="text/css" rel="stylesheet" href="/static/css/book_panel.css" />
{% endblock %} {% endblock %}
{% block base_js %} {% block base_js %}
<script src="/static/js/jquery-1.6.3.min.js"></script> <script src="/static/js/jquery-1.6.3.min.js"></script>
<!-- expands/collapses the learn more section --> <!-- expands/collapses the learn more section -->
<script type="text/javascript"> <script type="text/javascript">
var $j = jQuery.noConflict(); var $j = jQuery.noConflict();
$j(document).ready(function(){ $j(document).ready(function(){
$j('.user-block-hide').hide(); $j('.user-block-hide').hide();
$j('.user-block1 a').click( $j('.user-block1 a').click(
function() { function() {
$j(this).toggleClass("active"); $j(this).toggleClass("active");
$j(".user-block-hide").slideToggle(300); $j(".user-block-hide").slideToggle(300);
} }
); );
}); });
</script> </script>
<!-- toggle to panelview state instead of listview default --> <!-- toggle to panelview state instead of listview default -->
<script type="application/x-javascript"> <script type="application/x-javascript">
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
$('.listview').addClass("panelview").removeClass("listview"); $('.listview').addClass("panelview").removeClass("listview");
}); });
</script> </script>
<script type="text/javascript" src="/static/js/greenpanel.js"></script> <script type="text/javascript" src="/static/js/greenpanel.js"></script>
<script src="/static/js/slides.min.jquery.js"></script> <script src="/static/js/slides.min.jquery.js"></script>
<script> <script>
var $j = jQuery.noConflict(); var $j = jQuery.noConflict();
$j(function(){ $j(function(){
$j('#js-slideshow').slides({ $j('#js-slideshow').slides({
preload: true, preload: true,
preloadImage: '/static/images/landingpage/loading.gif', preloadImage: '/static/images/landingpage/loading.gif',
hoverPause: true, hoverPause: true,
generateNextPrev: true, generateNextPrev: true,
next: 'next', next: 'next',
prev: 'prev', prev: 'prev',
pagination: true, pagination: true,
generatePagination: false, generatePagination: false,
slideSpeed: 600, slideSpeed: 600,
autoHeight: true autoHeight: true
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}
{% block topsection %} {% block topsection %}
<div id="js-topsection"> <div id="js-topsection">
<div class="js-main"> <div class="js-main">
<div class="js-topnews"> <div class="js-topnews">
<div class="user-block"> <div class="user-block">
<div class="user-block1"> <div class="user-block1">
<div class="block-inner"> <div class="block-inner">
<div class="block-intro-text">With your help we raise money to buy book rights. The <span class="typo">unglued</span> books are free to download, here.</div> <div class="block-intro-text">With your help we raise money to buy book rights. The <span class="typo">unglued</span> books are free to download, here.</div>
<a class="my-setting readon"><span>Learn more</span></a> <a class="my-setting readon"><span>Learn more</span></a>
</div> </div>
</div> </div>
<div class="user-block2"> <div class="user-block2">
<div class="block-inner"> <div class="block-inner">
<label class="title">Spread the Word</label> <label class="title">Spread the Word</label>
<a href="https://www.facebook.com/sharer/sharer.php?src=bm&u=http://{{ request.META.HTTP_HOST }}{{ request.path }}"><img src="/static/images/supporter_icons/facebook_square.png" alt="Facebook" title="Facebook" /></a> <a href="https://www.facebook.com/sharer/sharer.php?src=bm&u=http://{{ request.META.HTTP_HOST }}{{ request.path }}"><img src="/static/images/supporter_icons/facebook_square.png" alt="Facebook" title="Facebook" /></a>
<a href="https://twitter.com/share"><img src="/static/images/supporter_icons/twitter_square.png" alt="tweeter" title="Twitter" /></a> <a href="https://twitter.com/share"><img src="/static/images/supporter_icons/twitter_square.png" alt="tweeter" title="Twitter" /></a>
</div> </div>
</div> </div>
</div> </div>
<div class="user-block-hide"> <div class="user-block-hide">
<p>We all have books we love so much, we'd like to give them to the world.</p> <p>We all have books we love so much, we'd like to give them to the world.</p>
<p> <p>
We want to share them, but also reward their creators. With digital books, it can be hard to do both. Unglue.it offers a win-win solution: We want to share them, but also reward their creators. With digital books, it can be hard to do both. Unglue.it offers a win-win solution:
</p> </p>
<p> <p>
Crowdfunding. We run pledge campaigns for books; you chip in. When, together, we've reached the goal, we'll reward the book's creators and issue an unglued ebook. Crowdfunding. We run pledge campaigns for books; you chip in. When, together, we've reached the goal, we'll reward the book's creators and issue an unglued ebook.
</p> </p>
<p> <p>
<a href="https://creativecommons.org/">Creative Commons</a> licensing means everyone, everywhere can read and share the unglued book — freely and legally. You've given your favorite book to the world. <a href="https://creativecommons.org/">Creative Commons</a> licensing means everyone, everywhere can read and share the unglued book — freely and legally. You've given your favorite book to the world.
</p> </p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div id="main-container" class="main-container-fl"> <div id="main-container" class="main-container-fl">
<div class="js-main"> <div class="js-main">
<div id="js-maincol-fl"> <div id="js-maincol-fl">
<div id="js-main-container"> <div id="js-main-container">
<div class="js-main-container-inner"> <div class="js-main-container-inner">
<div id="js-maincontainer-content" class="have-content-right-module"> <div id="js-maincontainer-content" class="have-content-right-module">
<div class="content-right-module"> <div class="content-right-module">
<h3>How does it work?</h3> <h3>How does it work?</h3>
</div> </div>
<div style="clear:right;"> <div style="clear:right;">
<div class="item-content"> <div class="item-content">
<h2 class="page-heading">Give books to the world.</h2> <h2 class="page-heading">Give books to the world.</h2>
</div> </div>
<div class="jsmod-content"> <div class="jsmod-content">
<img src="/static/images/landingpage/icon-group.png" alt="How does it work?" title="How does it work?" height="269" width="268" /> <img src="/static/images/landingpage/icon-group.png" alt="How does it work?" title="How does it work?" height="269" width="268" />
</div> </div>
</div> </div>
</div> </div>
<div id="js-maincontainer-bot-block"> <div id="js-maincontainer-bot-block">
<div id="js-search"> <div id="js-search">
<label>What book would you give to the world? </label> <label>What book would you give to the world? </label>
<form action="{% url search %}" method="get"> <form action="{% url search %}" method="get">
<input type="text" placeholder="Search for a book..." size="25" class="inputbox" name="q" value="{{ q }}"> <input type="text" placeholder="Search for a book..." size="25" class="inputbox" name="q" value="{{ q }}">
<input type="button" onclick="this.form.searchword.focus();" class="button" value="Search"> <input type="button" onclick="this.form.searchword.focus();" class="button" value="Search">
</form> </form>
</div> </div>
</div> </div>
<div id="js-maincontainer-faq"> <div id="js-maincontainer-faq">
<div class="js-maincontainer-faq-inner"> <div class="js-maincontainer-faq-inner">
Questions? Read our <a href="/stub/tour">FAQs</a> or take the <a href="/stub/tour">Tour</a> Questions? Read our <a href="/stub/tour">FAQs</a> or take the <a href="/stub/tour">Tour</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="js-rightcol"> <div id="js-rightcol">
<div class="js-rightcol-padd"> <div class="js-rightcol-padd">
<div class="jsmodule"> <div class="jsmodule">
<h3 class="module-title">Start Ungluing Now!</h3> <h3 class="module-title">Start Ungluing Now!</h3>
<div class="jsmod-content"> <div class="jsmod-content">
<form action='/accounts/register/' method='post'>{% csrf_token %} <form action='/accounts/register/' method='post'>{% csrf_token %}
<div class="user-name"> <div class="user-name">
<label>Username</label> <label>Username</label>
<input id="id_username" type="text" class="required" name="username" maxlength="30" size="25" /> <input id="id_username" type="text" class="required" name="username" maxlength="30" size="25" />
</div> </div>
<div class="email"> <div class="email">
<label>Email</label> <label>Email</label>
<input id="id_email" type="text" class="required" name="email" maxlength="75" size="25" /> <input id="id_email" type="text" class="required" name="email" maxlength="75" size="25" />
</div> </div>
<div class="password"> <div class="password">
<label>Password</label> <label>Password</label>
<input id="id_password1" type="password" class="required" name="password1" size="25" /> <input id="id_password1" type="password" class="required" name="password1" size="25" />
</div> </div>
<div class="password"> <div class="password">
<label>Password (again):</label> <label>Password (again):</label>
<input id="id_password2" type="password" class="required" name="password2" size="25" /> <input id="id_password2" type="password" class="required" name="password2" size="25" />
</div> </div>
<div class="button"> <div class="button">
<input type="submit" value="sign up" /> <input type="submit" value="sign up" />
</div> </div>
<div> <div>
<p><a href="/socialauth/login/google?next=http://{{ request.get_host }}{{ next }}"><img src="{{ STATIC_URL }}/images/auth/google_64.png">Sign In With Google</a></p> <p><a href="/socialauth/login/google?next=http://{{ request.get_host }}{{ next }}"><img src="{{ STATIC_URL }}/images/auth/google_64.png">Sign In With Google</a></p>
</div> </div>
</div> </div>
</div> </div>
<div class="jsmodule"> <div class="jsmodule">
<h3 class="module-title">Who's ungluing what</h3> <h3 class="module-title">Who's ungluing what</h3>
<div class="jsmod-content"> <div class="jsmod-content">
<ul class="ungluingwhat"> <ul class="ungluingwhat">
<li> {% for event in events %}
<div class="user-avatar"><img src="/static/images/landingpage/user-avatar.png" width="43" height="43" title="User sure Name" alt="User sure name" /></div> <li>
<div class="user-book-info"> <div class="user-avatar"><img src="{% if event.wishlist.user.picurl %}{{ event.wishlist.user.picurl}}{% else %}/static/images/landingpage/user-avatar.png{% endif %}" width="43" height="43" title="{{event.wishlist.user.username}}" alt="{{event.wishlist.user.username}} avatar" /></div>
<p class="user-book-info">Very Long Username is Wishing For </p> <div class="user-book-info">
<a class="user-book-name" href="#">Very Long Book Title</a> <p class="user-book-info"><a href="{% url supporter event.wishlist.user.username %}">{{event.wishlist.user.username}}</a> is Wishing For </p>
</div> <a class="user-book-name" href="{% url work event.work.id %}">{{ event.work.title }}</a>
<div class="user-book-thumb"><img src="/static/images/landingpage/user-bookthumb.png" width="29" height="43" title="Very Long Username is Wishing For" alt="Very Long Book Title" /></div> </div>
</li> <div class="user-book-thumb"><img src="{{ event.work.cover_image_thumbnail }}" width="29" height="43" title="{{ event.work.title }}" alt="Very Long Book Title" /></div>
<li> </li>
<div class="user-avatar"><img src="/static/images/landingpage/user-avatar.png" width="43" height="43" title="User sure Name" alt="User sure name" /></div> {% endfor %}
<div class="user-book-info"> </ul>
<p class="user-book-info">Very Long Username is Wishing For </p> </div>
<a class="user-book-name" href="#">Very Long Book Title</a> </div>
</div> </div>
<div class="user-book-thumb"><img src="/static/images/landingpage/user-bookthumb.png" width="29" height="43" title="Very Long Username is Wishing For" alt="Very Long Book Title" /></div> </div>
</li> </div>
<li> </div>
<div class="user-avatar"><img src="/static/images/landingpage/user-avatar.png" width="43" height="43" title="User sure Name" alt="User sure name" /></div> </div>
<div class="user-book-info">
<p class="user-book-info">Very Long Username is Wishing For </p> <div id="js-slide">
<a class="user-book-name" href="#">Very Long Book Title</a> <div class="js-main">
</div> <div class="jsmodule">
<div class="user-book-thumb"><img src="/static/images/landingpage/user-bookthumb.png" width="29" height="43" title="Very Long Username is Wishing For" alt="Very Long Book Title" /></div> <h3><span>Top ungluing campaigns</span></h3>
</li> <div class="jsmod-content">
</ul> <div id="js-slideshow">
</div> <div class="slides_container">
</div> <div class="slide-page slide-page1">
</div> {% for work in works %}
</div> <div class="spacer">
</div> {% include "book_panel.html" %}
</div> </div>
</div> {% endfor %}
</div>
<div id="js-slide"> <div class="slide-page slide-page2">
<div class="js-main"> {% for work in works2 %}
<div class="jsmodule"> <div class="spacer">
<h3><span>Top ungluing campaigns</span></h3> {% include "book_panel.html" %}
<div class="jsmod-content"> </div>
<div id="js-slideshow"> {% endfor %}
<div class="slides_container"> </div>
<div class="slide-page slide-page1"> </div>
{% for work in works %} </div>
<div class="spacer"> </div>
{% include "book_panel.html" %} </div>
</div> </div>
{% endfor %} </div>
</div>
<div class="slide-page slide-page2">
{% for work in works2 %}
<div class="spacer">
{% include "book_panel.html" %}
</div>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %} {% endblock %}

View File

@ -67,13 +67,17 @@ jQuery(document).ready(function(){
<h3 class="book-year">{{ work.editions.all.0.publication_date }}</h3> <h3 class="book-year">{{ work.editions.all.0.publication_date }}</h3>
<div class="find-book"> <div class="find-book">
<label>Find it here</label> <label>Find it here</label>
<!-- todo: these should be a real thing -->
<div class="find-link"> <div class="find-link">
<a class="find-google" href="{{ work.googlebooks_url }}"><img src="/static/images/icons/google.png" align="" title="Find on GoogleBooks" /></a> <a class="find-google" href="{{ work.googlebooks_url }}"><img src="/static/images/supporter_icons/googlebooks_square.png" align="" title="Find on Google Books" /></a>
<a rel="nofollow" class="find-librarything" href="{% url work_librarything work.id %}"><img src="/static/images/supporter_icons/librarything_square.png" title="Find on LibraryThing" /></a>
<a rel="nofollow" class="find-goodreads" href="{% url work_goodreads work.id %}"><img src="/static/images/supporter_icons/goodreads_square.png" title="Find on GoodReads"></a>
<a rel="nofollow" class="find-openlibrary" href="{% url work_openlibrary work.id %}"><img src="/static/images/supporter_icons/openlibrary_square.png" title="Find on OpenLibrary"></a> <a rel="nofollow" class="find-openlibrary" href="{% url work_openlibrary work.id %}"><img src="/static/images/supporter_icons/openlibrary_square.png" title="Find on OpenLibrary"></a>
<a class="find-group" href="#"><img src="/static/images/icons/group.png" align="" title="" /></a> {% if not request.user.is_anonymous %}
{% if request.user.profile.goodreads_user_link %}
<a rel="nofollow" class="find-goodreads" href="{% url work_goodreads work.id %}"><img src="/static/images/supporter_icons/goodreads_square.png" title="Find on GoodReads"></a>
{% endif %}
{% if request.user.profile.librarything_id %}
<a rel="nofollow" class="find-librarything" href="{% url work_librarything work.id %}"><img src="/static/images/supporter_icons/librarything_square.png" title="Find on LibraryThing" /></a>
{% endif %}
{% endif %}
</div> </div>
</div> </div>
{% if status == 'ACTIVE' %} {% if status == 'ACTIVE' %}
@ -162,9 +166,10 @@ jQuery(document).ready(function(){
<div id="tabs-4" class="tabs"> <div id="tabs-4" class="tabs">
<div class="tabs-content"> <div class="tabs-content">
{% if status == 'ACTIVE' %} {% if status == 'ACTIVE' %}
<h4>Last campaign details</h4>
{{ work.last_campaign.details|safe }} {{ work.last_campaign.details|safe }}
{% endif %} {% endif %}
{% if work.claim.count %} {% if work.claim.count %}
<h4> Rights Information </h4> <h4> Rights Information </h4>
<p> This work has been claimed by:</p> <p> This work has been claimed by:</p>
@ -186,6 +191,11 @@ jQuery(document).ready(function(){
</form> </form>
{% endif %} {% endif %}
{% endif %} {% endif %}
<h4>Editions</h4>
{% for edition in editions %}
<div class="editions"><div><img src="http://bks{{ server }}.books.google.com/books?id={{ edition.googlebooks_id }}&printsec=frontcover&img=1&zoom=5" /></div><div class="metadata">{{edition.publisher}}<br />{{edition.publication_date}}<br /><a href="http://bks{{ server }}.books.google.com/books?id={{ edition.googlebooks_id }}">This edition on Google Books</a></div></div>
{% endfor %}
</div> </div>
</div> </div>
</div> </div>

View File

@ -6,6 +6,7 @@ import logging
import datetime import datetime
from decimal import Decimal as D from decimal import Decimal as D
from re import sub from re import sub
from random import randint
from django import forms from django import forms
from django.db.models import Q, Count, Sum from django.db.models import Q, Count, Sum
@ -67,7 +68,8 @@ def home(request):
j += 1 j += 1
if j == count: if j == count:
j = 0 j = 0
return render(request, 'home.html', {'suppress_search_box': True, 'works': works, 'works2': works2}) events = models.Wishes.objects.order_by('-created')[0:2]
return render(request, 'home.html', {'suppress_search_box': True, 'works': works, 'works2': works2, 'events': events})
def stub(request): def stub(request):
path = request.path[6:] # get rid of /stub/ path = request.path[6:] # get rid of /stub/
@ -75,7 +77,10 @@ def stub(request):
def work(request, work_id, action='display'): def work(request, work_id, action='display'):
work = get_object_or_404(models.Work, id=work_id) work = get_object_or_404(models.Work, id=work_id)
editions = work.editions.all()
campaign = work.last_campaign() campaign = work.last_campaign()
server = randint(0,9)
if not request.user.is_anonymous(): if not request.user.is_anonymous():
claimform = UserClaimForm( request.user, data={'work':work_id, 'user': request.user.id}) claimform = UserClaimForm( request.user, data={'work':work_id, 'user': request.user.id})
else: else:
@ -100,6 +105,8 @@ def work(request, work_id, action='display'):
'claimform': claimform, 'claimform': claimform,
'wishers': wishers, 'wishers': wishers,
'base_url': base_url, 'base_url': base_url,
'editions': editions,
'server': server,
}) })
def manage_campaign(request, id): def manage_campaign(request, id):
@ -555,12 +562,12 @@ def wishlist(request):
edition = bookloader.add_by_googlebooks_id(googlebooks_id) edition = bookloader.add_by_googlebooks_id(googlebooks_id)
# add related editions asynchronously # add related editions asynchronously
tasks.add_related.delay(edition.isbn_10) tasks.add_related.delay(edition.isbn_10)
request.user.wishlist.works.add(edition.work) request.user.wishlist.add_work(edition.work,'user')
# TODO: redirect to work page, when it exists # TODO: redirect to work page, when it exists
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
elif remove_work_id: elif remove_work_id:
work = models.Work.objects.get(id=int(remove_work_id)) work = models.Work.objects.get(id=int(remove_work_id))
request.user.wishlist.works.remove(work) request.user.wishlist.remove_work(work)
# TODO: where to redirect? # TODO: where to redirect?
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
@ -858,7 +865,6 @@ def work_librarything(request, work_id):
term = work.title + " " + work.author() term = work.title + " " + work.author()
q = urllib.urlencode({'searchtpe': 'work', 'term': term}) q = urllib.urlencode({'searchtpe': 'work', 'term': term})
url = "http://www.librarything.com/search.php?" + q url = "http://www.librarything.com/search.php?" + q
print url
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
def work_openlibrary(request, work_id): def work_openlibrary(request, work_id):

View File

@ -250,7 +250,7 @@ ul.support li span.menu-item-price {
float: left; float: left;
margin-left: 5px; margin-left: 5px;
} }
/* differs from sitewide.css. should it? */ /* this line differs from sitewide.css. should it? */
a { a {
color: #3d4e53; color: #3d4e53;
font-size: 12px; font-size: 12px;
@ -275,3 +275,15 @@ a {
background: url("/static/images/booklist/add-wishlist.png") left center no-repeat; background: url("/static/images/booklist/add-wishlist.png") left center no-repeat;
padding-left: 20px; padding-left: 20px;
} }
.editions {
clear: both;
}
.editions div {
float: left;
padding-bottom: 5px;
}
.editions .metadata {
display: block;
overflow: hidden;
margin-left: 5px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -273,7 +273,7 @@ ul.support li {
} }
} }
/* differs from sitewide.css. should it? */ /* this line differs from sitewide.css. should it? */
a{ color:#3d4e53; font-size:12px;} a{ color:#3d4e53; font-size:12px;}
.add-wishlist, &.remove-wishlist, &.on-wishlist, &.create-account { .add-wishlist, &.remove-wishlist, &.on-wishlist, &.create-account {
@ -290,4 +290,19 @@ a{ color:#3d4e53; font-size:12px;}
background:url("@{image-base}booklist/add-wishlist.png") left center no-repeat; background:url("@{image-base}booklist/add-wishlist.png") left center no-repeat;
padding-left:20px; padding-left:20px;
} }
}
.editions {
clear: both;
div {
float:left;
padding-bottom: 5px;
}
.metadata {
display:block;
overflow: hidden;
margin-left: 5px;
}
} }