Merge pull request #311 from Gluejar/improve_editions

Improve editions
pull/1/head
Raymond Yee 2014-03-13 13:53:08 -07:00
commit 6c62c56f77
15 changed files with 711 additions and 285 deletions

View File

@ -118,7 +118,6 @@ def get_google_isbn_results(isbn):
def add_ebooks(item, edition):
access_info = item.get('accessInfo')
if access_info:
edition.public_domain = access_info.get('publicDomain', None)
epub = access_info.get('epub')
if epub and epub.get('downloadLink'):
ebook = models.Ebook(edition=edition, format='epub',

View File

@ -300,7 +300,6 @@
"title": "Pro Web 2.0 Mashups",
"work": 1,
"created": "2012-10-12T23:27:53",
"public_domain": null,
"cover_image": null,
"publication_date": "2008-03-07",
"unglued": false
@ -321,7 +320,6 @@
"title": "Moby Dick",
"work": 2,
"created": "2012-10-14T09:54:17",
"public_domain": null,
"cover_image": null,
"publication_date": "1902",
"unglued": false
@ -342,7 +340,6 @@
"title": "Mass in B Minor in Full Score",
"work": 3,
"created": "2012-10-14T10:01:54",
"public_domain": null,
"cover_image": null,
"publication_date": "1989-06-01",
"unglued": false

View File

@ -0,0 +1,357 @@
# -*- coding: 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 'Work.selected_edition'
db.add_column('core_work', 'selected_edition',
self.gf('django.db.models.fields.related.ForeignKey')(related_name='selected_works', null=True, to=orm['core.Edition']),
keep_default=False)
# Adding field 'Work.earliest_publication'
db.add_column('core_work', 'earliest_publication',
self.gf('django.db.models.fields.CharField')(max_length=50, null=True),
keep_default=False)
# Deleting field 'Edition.public_domain'
db.delete_column('core_edition', 'public_domain')
def backwards(self, orm):
# Deleting field 'Work.selected_edition'
db.delete_column('core_work', 'selected_edition_id')
# Deleting field 'Work.earliest_publication'
db.delete_column('core_work', 'earliest_publication')
# Adding field 'Edition.public_domain'
db.add_column('core_edition', 'public_domain',
self.gf('django.db.models.fields.NullBooleanField')(null=True, blank=True),
keep_default=False)
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'})
},
'booxtream.boox': {
'Meta': {'object_name': 'Boox'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'download_link_epub': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'}),
'download_link_mobi': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True'}),
'downloads_remaining': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '0'}),
'expirydays': ('django.db.models.fields.PositiveSmallIntegerField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'referenceid': ('django.db.models.fields.CharField', [], {'max_length': '32'})
},
'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.acq': {
'Meta': {'object_name': 'Acq'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'expires': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'lib_acq': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'loans'", 'null': 'True', 'to': "orm['core.Acq']"}),
'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, 3, 10, 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']"})
},
'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.badge': {
'Meta': {'object_name': 'Badge'},
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '72', 'blank': 'True'})
},
'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'}),
'cc_date_initial': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'deadline': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'db_index': 'True'}),
'description': ('ckeditor.fields.RichTextField', [], {'null': 'True'}),
'details': ('ckeditor.fields.RichTextField', [], {'null': 'True', 'blank': 'True'}),
'do_watermark': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'dollar_per_day': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'null': 'True', 'to': "orm['core.Edition']"}),
'email': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'left': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}),
'license': ('django.db.models.fields.CharField', [], {'default': "'CC BY-NC-ND'", 'max_length': '255'}),
'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'}),
'publisher': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'null': 'True', 'to': "orm['core.Publisher']"}),
'status': ('django.db.models.fields.CharField', [], {'default': "'INITIALIZED'", 'max_length': '15', 'null': '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'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'campaigns'", 'to': "orm['core.Work']"})
},
'core.campaignaction': {
'Meta': {'object_name': 'CampaignAction'},
'campaign': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'actions'", 'to': "orm['core.Campaign']"}),
'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'timestamp': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '15'})
},
'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, 3, 10, 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'}),
'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'}),
'download_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'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', 'db_index': 'True'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '1024'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'})
},
'core.ebookfile': {
'Meta': {'object_name': 'EbookFile'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ebook_files'", 'to': "orm['core.Edition']"}),
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'format': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
},
'core.edition': {
'Meta': {'object_name': 'Edition'},
'cover_image': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
'publisher_name': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.PublisherName']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'unglued': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'editions'", 'null': 'True', 'to': "orm['core.Work']"})
},
'core.hold': {
'Meta': {'object_name': 'Hold'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'library': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'holds'", 'to': "orm['libraryauth.Library']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'holds'", 'to': "orm['auth.User']"}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'holds'", 'to': "orm['core.Work']"})
},
'core.identifier': {
'Meta': {'unique_together': "(('type', 'value'),)", 'object_name': 'Identifier'},
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'identifiers'", 'null': 'True', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
'value': ('django.db.models.fields.CharField', [], {'max_length': '31'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'identifiers'", 'to': "orm['core.Work']"})
},
'core.key': {
'Meta': {'object_name': 'Key'},
'encrypted_value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'core.libpref': {
'Meta': {'object_name': 'Libpref'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'marc_link_target': ('django.db.models.fields.CharField', [], {'default': "'UNGLUE'", 'max_length': '6'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'libpref'", 'unique': 'True', 'to': "orm['auth.User']"})
},
'core.marcrecord': {
'Meta': {'object_name': 'MARCRecord'},
'edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'MARCrecords'", 'null': 'True', 'to': "orm['core.Edition']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'link_target': ('django.db.models.fields.CharField', [], {'default': "'DIRECT'", 'max_length': '6'})
},
'core.offer': {
'Meta': {'object_name': 'Offer'},
'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'license': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1'}),
'price': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '6', 'decimal_places': '2'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'offers'", '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'}),
'limit': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
'type': ('django.db.models.fields.CharField', [], {'max_length': '2'})
},
'core.press': {
'Meta': {'object_name': 'Press'},
'date': ('django.db.models.fields.DateField', [], {}),
'highlight': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'max_length': '20', 'blank': 'True'}),
'note': ('django.db.models.fields.CharField', [], {'max_length': '140', 'blank': 'True'}),
'source': ('django.db.models.fields.CharField', [], {'max_length': '140'}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '140'}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '200'})
},
'core.publisher': {
'Meta': {'object_name': 'Publisher'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'logo_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}),
'name': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'key_publisher'", 'to': "orm['core.PublisherName']"}),
'url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'})
},
'core.publishername': {
'Meta': {'object_name': 'PublisherName'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'publisher': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'alternate_names'", 'null': 'True', 'to': "orm['core.Publisher']"})
},
'core.rightsholder': {
'Meta': {'object_name': 'RightsHolder'},
'can_sell': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'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'})
},
'core.subject': {
'Meta': {'ordering': "['name']", 'object_name': 'Subject'},
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'}),
'works': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'subjects'", 'symmetrical': 'False', 'to': "orm['core.Work']"})
},
'core.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'avatar_source': ('django.db.models.fields.PositiveSmallIntegerField', [], {'default': '1', 'null': 'True'}),
'badges': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'holders'", 'symmetrical': 'False', 'to': "orm['core.Badge']"}),
'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'}),
'kindle_email': ('django.db.models.fields.EmailField', [], {'max_length': '254', 'blank': '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.waswork': {
'Meta': {'object_name': 'WasWork'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'moved': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}),
'was': ('django.db.models.fields.IntegerField', [], {'unique': 'True'}),
'work': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['core.Work']"})
},
'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', [], {'related_name': "'wishes'", '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'}),
'description': ('django.db.models.fields.TextField', [], {'default': "''", 'null': 'True', 'blank': 'True'}),
'earliest_publication': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'language': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '2'}),
'num_wishes': ('django.db.models.fields.IntegerField', [], {'default': '0', 'db_index': 'True'}),
'openlibrary_lookup': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'selected_edition': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'selected_works'", 'null': 'True', 'to': "orm['core.Edition']"}),
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'})
},
'libraryauth.library': {
'Meta': {'object_name': 'Library'},
'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'backend': ('django.db.models.fields.CharField', [], {'default': "'ip'", 'max_length': '10'}),
'group': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'library'", 'unique': 'True', 'null': 'True', 'to': "orm['auth.Group']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '80'}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'libraries'", 'to': "orm['auth.User']"}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'library'", 'unique': 'True', 'to': "orm['auth.User']"})
}
}
complete_apps = ['core']

View File

@ -1032,6 +1032,9 @@ class Work(models.Model):
openlibrary_lookup = models.DateTimeField(null=True)
num_wishes = models.IntegerField(default=0, db_index=True)
description = models.TextField(default='', null=True, blank=True)
selected_edition = models.ForeignKey("Edition", related_name = 'selected_works', null = True)
earliest_publication = models.CharField(max_length=50, null=True)
class Meta:
ordering = ['title']
@ -1144,10 +1147,19 @@ class Work(models.Model):
@property
def preferred_edition(self):
if self.selected_edition:
return self.selected_edition
if self.last_campaign():
if self.last_campaign().edition:
self.selected_edition = self.last_campaign().edition
self.save()
return self.last_campaign().edition
return self.editions.all()[0] if self.editions.all().count() else None
try:
self.selected_edition = self.editions.all()[0]
self.save()
return self.selected_edition
except IndexError:
return None
def last_campaign_status(self):
campaign = self.last_campaign()
@ -1269,8 +1281,12 @@ class Work(models.Model):
@property
def publication_date(self):
for edition in Edition.objects.filter(work=self):
if self.earliest_publication:
return self.earliest_publication
for edition in Edition.objects.filter(work=self, publication_date__isnull=False).order_by('publication_date'):
if edition.publication_date:
self.earliest_publication = edition.publication_date
self.save()
return edition.publication_date
return ''
@ -1441,7 +1457,6 @@ class Edition(models.Model):
title = models.CharField(max_length=1000)
publisher_name = models.ForeignKey("PublisherName", related_name="editions", null=True)
publication_date = models.CharField(max_length=50, null=True, blank=True)
public_domain = models.NullBooleanField(null=True, blank=True)
work = models.ForeignKey("Work", related_name="editions", null=True)
cover_image = models.URLField(null=True, blank=True)
unglued = models.BooleanField(blank=True)

View File

@ -335,7 +335,6 @@ class BookLoaderTests(TestCase):
self.assertEqual(parse_qs(urlparse(ebook_pdf.url).query).get("id"), ['N1RfAAAAMAAJ'])
self.assertEqual(parse_qs(urlparse(ebook_pdf.url).query).get("output"), ['pdf'])
self.assertEqual(ebook_pdf.provider, 'Google Books')
self.assertEqual(edition.public_domain, True)
w = edition.work
self.assertEqual(w.first_epub().url, ebook_epub.url)

View File

@ -20,6 +20,8 @@ from django.forms.widgets import RadioSelect
from django.forms.extras.widgets import SelectDateWidget
from django.utils.translation import ugettext_lazy as _
from ckeditor.widgets import CKEditorWidget
from selectable.forms import (
AutoCompleteSelectMultipleWidget,
AutoCompleteSelectMultipleField,
@ -127,7 +129,7 @@ class EditionForm(forms.ModelForm):
}
)
language = forms.ChoiceField(choices=LANGUAGES)
description = forms.CharField( required=False, widget= forms.Textarea(attrs={'cols': 80, 'rows': 2}))
description = forms.CharField( required=False, widget= forms.Textarea(attrs={'cols': 80, 'rows': 10}))
coverfile = forms.ImageField(required=False)
def clean(self):
@ -446,7 +448,7 @@ class DateCalculatorForm(CCDateForm, forms.ModelForm):
model = Campaign
fields = 'target', 'cc_date_initial', 'revenue',
def getManageCampaignForm ( instance, data=None, *args, **kwargs ):
def getManageCampaignForm ( instance, data=None, initial=None, *args, **kwargs ):
def get_queryset():
work=instance.work
@ -469,6 +471,7 @@ def getManageCampaignForm ( instance, data=None, *args, **kwargs ):
)
edition = forms.ModelChoiceField(get_queryset(), widget=RadioSelect(),empty_label='no edition selected',required = False,)
publisher = forms.ModelChoiceField(instance.work.publishers(), empty_label='no publisher selected', required = False,)
work_description = forms.CharField( required=False , widget=CKEditorWidget())
class Meta:
model = Campaign
@ -527,7 +530,7 @@ def getManageCampaignForm ( instance, data=None, *args, **kwargs ):
elif self.instance.license == 'CC0' :
raise forms.ValidationError(_('The proposed license for an ACTIVE campaign may not add restrictions.'))
return new_license
return ManageCampaignForm(instance = instance, data=data)
return ManageCampaignForm(instance = instance, data=data, initial=initial)
class CampaignPurchaseForm(forms.Form):
anonymous = forms.BooleanField(required=False, label=_("Make this purchase anonymous, please"))

View File

@ -0,0 +1,48 @@
<div class="clearfix">
<div class="editions">
{% if edition.googlebooks_id %}
<div class="image">
<img src="{{ edition.cover_image_small }}" title="edition cover" alt="edition cover" />
</div>
{% endif %}
<div class="metadata" id="edition_{{edition.id}}">
{% ifnotequal edition.title work.title %}
Title: {{edition.title}}<br />
{% endifnotequal %}
{% if edition.authors.all.0 %}
Contributors:
{% for author in edition.authors.all %}
{{author}},
{% endfor %}
<br />
{% endif %}
{% if edition.publisher %}
Publisher: <a href="{% url bypubname_list edition.publisher_name.id %}">{{edition.publisher}}</a><br />
{% endif %}
{% if edition.publication_date %}
Published: {{ edition.publication_date }}<br />
{% endif %}
{% if edition.isbn_13 %}
ISBN: <span itemprop="isbn">{{ edition.isbn_13 }}</span><br />
{% endif %}
{% if edition.oclc %}
OCLC: <a href="http://www.worldcat.org/oclc/{{ edition.oclc }}">{{ edition.oclc }}</a><br />
{% endif %}
{% if user.is_staff %}
<a href="{% url new_edition work_id edition.id %}">Edit this edition/Add ebook</a><br />
{% else %}{% if user in work.last_campaign.managers.all %}
<a href="{% url new_edition work_id edition.id %}">Edit this edition/Add ebook</a><br />
{% endif %}{% endif %}
{% if edition.googlebooks_id %}
See <a href="https://encrypted.google.com/books?id={{ edition.googlebooks_id }}">this edition on Google Books</a><br />
{% endif %}
{% for record in edition.MARCrecords.all %}
Download {{record.link_target}} MARC record for this edition: (<a href="{% url marc_concatenate %}?record_{{ record.id }}=on&amp;format=xml">XML</a>) (<a href="{% url marc_concatenate %}?record_{{ record.id }}=on&amp;format=mrc">mrc</a>)<br />
{% endfor %}
{% if user.is_staff %}{% if edition.ebooks.0 or edition.ebook_files.0 %}
<a href="{% url MARCUngluify %}?edition={{ edition.id }}">Upload</a> a MARC record for this edition. <br />
{% endif %} {% endif %}
</div>
</div>
</div>

View File

@ -0,0 +1,31 @@
<div class="clearfix">
{% if edition.ebook_form %}
{% if show_ebook_form %}
<div id="add_ebook">
{% if edition.ebooks.all.0 %}
<h2>eBooks for this Edition</h2>
{% if alert %}<div class="yikes">{{alert}}</div>{% endif %}
{% for ebook in edition.ebooks.all %}
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }}</a> {{ebook.rights}} at {{ebook.provider}}. Downloaded {{ ebook.download_count }} times.<br />
{% endfor %}
{% endif %}
<h2>Add an eBook for this Edition:</h2>
<span>If you know that this edition is available as a public domain or Creative Commons ebook, you can enter the link here and "unglue" it. Right now, we're only accepting URLs that point to Internet Archive, Wikisources, Hathitrust, Project Gutenberg, or Google Books.</span>
<form method="POST" action="#add_ebook">
{% csrf_token %}{{ edition.ebook_form.edition.errors }}{{ edition.ebook_form.edition }}{{ edition.ebook_form.user.errors }}{{ edition.ebook_form.user }}{{ edition.ebook_form.provider.errors }}{{ edition.ebook_form.provider }}
{{ edition.ebook_form.url.errors }}<span>URL: {{ edition.ebook_form.url }}</span><br />
{{ edition.ebook_form.format.errors }}<span>File Format: {{ edition.ebook_form.format }}</span>&nbsp;&nbsp;&nbsp;
{{ edition.ebook_form.rights.errors }}<span>License: {{ edition.ebook_form.rights }}</span><br />
<input type="submit" name="add_ebook" value="add ebook" />
</form>
</div>
{% else %}
<div> Adding ebook links is disabled for this work.</div>
{% endif %}
{% endif %}
</div>

View File

@ -117,6 +117,7 @@ Please fix the following before launching your campaign:
<p> If you want to sell ebooks as part of a buy to unglue campaign, you'll also need to upload an EPUB file for the ebook you want to sell. </p>
{% endif %}
<ul>
<li><a href="{% url new_edition campaign.work.id '' %}"> Create a new edition</a> for this work</li>
{% for edition in campaign.work.editions.all %}
<li>Edition: <i>{{ edition }}</i>
<ul>
@ -162,7 +163,10 @@ Please fix the following before launching your campaign:
<p> This is the license you are offering to use once the campaign succeeds. For more information on the licenses you can use, see <a href="http://creativecommons.org/licenses">Creative Commons: About the Licenses</a>. Once your campaign is active, you'll be able to switch to a less restrictive license, but not a more restrictive one. We encourage you to pick the least restrictive license you are comfortable with, as this will increase the ways people can use your unglued ebook and motivate more people to donate.</p>
{% else %}
<h3>License Being Used</h3>
<p> This is the license you are using. For more information on the licenses you can use, see <a href="http://creativecommons.org/licenses">Creative Commons: About the Licenses</a>. Once your campaign is active, you'll be able to switch to a less restrictive license, but not a more restrictive one. We encourage you to pick the least restrictive license you are comfortable with, as this will increase the ways people can use your unglued ebook and motivate more people to donate.</p>
<p> This is the license you are using. For more information on the licenses you can use, see <a href="http://creativecommons.org/licenses">Creative Commons: About the Licenses</a>.
Once your campaign is active, you'll be able to switch to a less restrictive license, but not a more restrictive one.
We encourage you to pick the least restrictive license you are comfortable with, as this will increase the ways people can use your unglued ebook and motivate more people to participate.
</p>
{% endifnotequal %}
<div>
{{ form.license.errors }}{{ form.license }}
@ -252,18 +256,22 @@ Please fix the following before launching your campaign:
{% endifequal %}{{ form.do_watermark.errors }}
<h3>Make Your Pitch</h3>
<h3>Your Pitch</h3>
{% ifequal campaign.type 3 %}
<p>This will be displayed to a user who has clicked a "download" button. It's your chance to ask for their support. The user can either accept the suggested contribution and go make a payment, or enter "0" and go straight to download. To see your request in test mode, <a href="{% url download campaign.work.id %}?testmode=1">click here</a>. </p>
{% else %}
<p>This will be displayed in the Campaign tab for your work. It's your main pitch to supporters/purchasers.</p>
{% endifequal %}
<p>This isn't a dry synopsis in a catalog. It's your chance to be creative, to share your passion for this work, and to inspire readers. A strong pitch:</p>
<p>In a "thanks for ungluing" campaign, you want to first "motivate" your book- that is, you want to get the user to download the book.
Once the user has clicked a "Download" button or a "Read it Now" button, you have a chance for an "ask" - that's where a user can decide to also make a thank-you contribution.
The "ask" will be displayed to a user who has clicked a "Download" button. It's your chance to ask for their support.
The user can decide to make a contribution and go enter a credit card, or can scroll down to download.
To see your request in test mode, <a href="{% url download campaign.work.id %}?testmode=1">click here</a>. </p>
<p>A strong ask/motivation combination:</p>
{% else %}
<p>This will be displayed in the Campaign tab for your work. It's your main pitch to supporters/purchasers, and your chance to share your passion for this work, and to inspire readers..</p>
<p>A strong ask:</p>
{% endifequal %}
<ul class="terms">
{% ifequal campaign.type 3 %}
<li>Thanks the user for their interest in the book.</li>
<li>Makes a connection to the user while explaining how their contribution will make your work possible.</li>
<li>Makes a connection to the user while explaining how a contribution makes your work possible.</li>
<li>Speaks visually to the user (photos and/or videos). The FAQ has <a hef="{% url faq_sublocation 'campaigns' 'addingmedia' %}">instruction on adding media</a>.</li>
{% else %}
<li>Introduces the work. What's this book like?</li>
@ -279,6 +287,11 @@ Please fix the following before launching your campaign:
{% endifequal %}
</ul>
<br />
{% ifequal campaign.type 3 %}
<div style="padding-top:2em;padding-bottom:0.5em">First, the <b>Motivation</b>. Note that users who immediately click on a "Read it Now" button won't see this.:</div>
{{ form.work_description.errors }}{{ form.work_description }}
<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 %}
{{ form.description.errors }}{{ form.description }}
<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:

View File

@ -36,7 +36,7 @@
{% endif %}
<h2>More Edition Management</h2>
<div><a href="{% url split work.id %}">Remove editions from this work</a><br /><br /></div>
<div><a href="{% url work_editions work.id %}">Remove editions from this work</a><br /><br /></div>
<div><a href="{% url new_edition work.id '' %}">Create a new edition for this work</a><br /><br /></div>
{% endblock %}

View File

@ -9,12 +9,17 @@
{% endblock %}
{% block doccontent %}
{% if edition.pk %}
<h2>Edit Edition</h2>
{% if admin %}
{% if edition.pk %}
<h2>Edit Edition / Add Ebook Links</h2>
{% else %}
<h2>Create New Edition</h2>
{% endif %}
{% else %}
<h2>Create New Edition</h2>
<h2>Add Ebook Links</h2>
{% endif %}
{% if admin %}
<p>Title and ISBN 13 are required; the rest is optional, though a cover image link is strongly recommended.</p>
<form enctype="multipart/form-data" method="POST" action="#">
{% csrf_token %}
@ -22,7 +27,7 @@
{{ form.non_field_errors }}
<div>
<p><b>Title</b>: {{ form.title.errors }}{{ form.title }}</p>
<p><b>Publisher</b> : {{ form.publisher_name.errors }}{{ form.publisher_name }}<br />(If you change this, click another form element before submitting)</p>
<p><b>Publisher Name</b> : {{ form.publisher_name.errors }}{{ form.publisher_name }}<br />(If you change this, click another form element before submitting)</p>
<p>
<b>Authors</b>:
@ -59,11 +64,10 @@
{{ form.description.errors }}{{ form.description }}<br />
(<I>This will appear in the Description tab on the book page. If you create a campaign for this work, the campaign pitch will override this description</i>)</p>
<p><b>Publisher</b>: {{ form.publisher.errors }}{{ form.publisher }}</p>
<p><i>(Unglue.it participating publishers only.)</i><br /><b>Publisher</b>: {{ form.publisher.errors }}{{ form.publisher }}</p>
<p><b>Publication Date</b> (<I>four-digit year</I>): {{ form.publication_date.errors }}{{ form.publication_date }}</p>
<p><b>Public Domain?</b>: {{ form.public_domain.errors }}{{ form.public_domain }}</p>
{% comment %}
this has been removed since there's no point in exposing subject functionality when we're not doing anything with it -- will just confuse people.
@ -94,17 +98,25 @@
{{ form.coverfile.errors }}{{ form.coverfile }}{{ form.coverfile.help_text }}
(<i>upload a cover image file, ideally 120px wide. </i>)<br />
</p>
{% if request.user.is_staff %}
<p><b>Is this the unglued edition?</b> {{ form.unglued }}</p>
{% endif %}
</div>
<input type="submit" name="create_new_edition" value="{% if edition.pk %}Save Edits{% else %}Create Edition{% endif %}" id="submit">
</form>
{% if edition.work %}
<h2>More Edition Management</h2>
<div><a href="{% url merge edition.work.id %}">Merge other works into this one</a></div>
<div><a href="{% url split edition.work.id %}">Remove editions from this work</a><br /><br /></div>
<div><a href="{% url work_editions edition.work.id %}">Remove editions from this work</a><br /><br /></div>
{% endif %}
{% else %}
{% if edition.work %}
{% include 'edition_display.html' %}
{% else %}
Sorry, there's no work specified.
{% endif %}
{% endif %}
{% include 'edition_upload.html' %}
{% endblock %}

View File

@ -1,33 +1,14 @@
{% extends "basedocumentation.html" %}
{% block doccontent %}
<h2 class="book-name"><a href="{% url work work.id %}">{{ work.title }}</a></h2>
<h2>Split Editions</h2>
<form method="POST" action="#">
{% csrf_token %}
{{ formset.management_form }}
<dl>
{% for form in formset %}
<dt class="editionbox">
{{ form.instance.title }}, published by {{form.instance.publisher}} in {{ form.instance.publication_date }}
</dt>
<dd>with authors
{% for author in form.instance.authors.all %}
{{author}},
{% endfor %}
<br />
ISBN: {{ form.instance.isbn_13 }}
<br />
{{ form.id }}Split this Edition: {{form.DELETE.0}}
</dd>
{% endfor %}
</dl>
<input type="submit" value="Split Editions" name="submit" />
</form>
<h2>More Edition Management</h2>
<div><a href="{% url merge work.id %}">Merge other works into this one</a></div>
<div><a href="{% url new_edition work.id '' %}">Create a new edition for this work</a><br /><br /></div>
{% endblock %}
<form method="POST" action="#">
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
{% if request.user.is_staff %}
<div style="float:right;text-align:right">{{ form.id }}Split: {{form.DELETE.0}}<br /><br />
Select: <input type="radio" value="{{ form.instance.id }}" name="select_edition" /></div>
{% endif %}
{% with form.instance as edition %}
{% include 'edition_display.html' %}
{% endwith %}
{% endfor %}
{% if request.user.is_staff %}<input type="submit" value="Split/Select Editions" name="submit" />{% endif %}
</form>

View File

@ -8,7 +8,7 @@
{{ work.title }} is a Free eBook
{% else %}
Help us make {{ work.title }} a Free eBook!
{% endif %}
{% endif %}{% ifequal action 'editions' %} All Editions{% endifequal %}
{% endblock %}
{% block extra_css %}
@ -242,6 +242,16 @@
</div>
</div>
{% get_comment_count for work as comment_count %}
{% ifequal action 'editions' %}
<div class="content-block-heading" id="tabs">
<ul class="tabs">
<li class="tabs1"><a href="{% url work work.id %}?tab=1">{% if status == 'ACTIVE' %}Campaign{% else %}Description{% endif %}</a></li>
<li class="tabs2"><a href="{% url work work.id %}?tab=2">Comments {% if comment_count > 0 %}({{ comment_count }}){% endif %}</a></li>
<li class="tabs3" id="supporters"><a href="{% url work work.id %}?tab=3">Ungluers {% if wishers > 0 %}<br />({{ wishers }}){% endif %}</a></li>
<li class="tabs4 active"><a href="#">Editions</a></li>
</ul>
</div>
{% else %}
<div class="content-block-heading" id="tabs">
<ul class="tabs">
<li class="tabs1 {% if activetab == '1' %}active{% endif %}"><a href="#">{% if status == 'ACTIVE' %}Campaign{% else %}Description{% endif %}</a></li>
@ -250,7 +260,7 @@
<li class="tabs4 {% if activetab == '4' %}active{% endif %}"><a href="#">More...</a></li>
</ul>
</div>
{% endifequal %}
<div id="content-block-content">
<div id="tabs-1" class="tabs {% if activetab == '1' %}active{% endif %}">
<div class="tabs-content">
@ -325,174 +335,124 @@
</div>
<div id="tabs-4" class="tabs {% if activetab == '4' %}active{% endif %}">
<div class="tabs-content">
{% if status == 'ACTIVE' %}
{% ifequal work.last_campaign.type 1 %}
<h3 class="tabcontent-title">A campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) if ungluers can join together to raise ${{ work.last_campaign.target|floatformat:0|intcomma }} by {{ work.last_campaign.deadline }}.
You can help!</p>
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
<h3 class="tabcontent-title">A Buy-to-Unglue Campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) on {{ work.last_campaign.cc_date }}. For every copy that ungluers purchase, that date gets sooner. ${{ work.last_campaign.left|floatformat:0|intcomma }} of sales will unglue the book <i>TODAY</i>.
You can help!</p>
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<h3 class="tabcontent-title">A Thanks-for-Ungluing Campaign is running to reward the creators of <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has released <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) .
You can help us say "Thank You!" so that other creators will do the same.</p>
{% endifequal %}
<h4>Campaign details: the fine print</h4>
{{ work.last_campaign.details|safe }}
{% endif %}
{% ifequal action 'display' %}
{% if status == 'ACTIVE' %}
{% ifequal work.last_campaign.type 1 %}
<h3 class="tabcontent-title">A campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) if ungluers can join together to raise ${{ work.last_campaign.target|floatformat:0|intcomma }} by {{ work.last_campaign.deadline }}.
You can help!</p>
{% endifequal %}
{% ifequal work.last_campaign.type 2 %}
<h3 class="tabcontent-title">A Buy-to-Unglue Campaign is running to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) on {{ work.last_campaign.cc_date }}. For every copy that ungluers purchase, that date gets sooner. ${{ work.last_campaign.left|floatformat:0|intcomma }} of sales will unglue the book <i>TODAY</i>.
You can help!</p>
{% endifequal %}
{% ifequal work.last_campaign.type 3 %}
<h3 class="tabcontent-title">A Thanks-for-Ungluing Campaign is running to reward the creators of <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has released <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) .
You can help us say "Thank You!" so that other creators will do the same.</p>
{% endifequal %}
<h4>Campaign details: the fine print</h4>
{{ work.last_campaign.details|safe }}
{% endif %}
{% if status == 'SUCCESSFUL' %}
<h3 class="tabcontent-title">A campaign has succeeded to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) thanks to the efforts of ungluers like you.</p>
<h4>Campaign details: the fine print</h4>
{{ work.last_campaign.details|safe }}
{% endif %}
{% if status != 'ACTIVE' and status != 'SUCCESSFUL' %}
<h4> Rights Information </h4>
{% if claimstatus == 'one_active' %}
<p>This work has been claimed by {{ rights_holder_name }}.</p>
{% else %}
{% if claimstatus == 'disputed' %}
<p>Rights claims are pending.</p>
{% if status == 'SUCCESSFUL' %}
<h3 class="tabcontent-title">A campaign has succeeded to unglue <i>{{work.title}}</i>!</h3>
<p>The rights holder, {% for claim in work.claim.all %}
{% if claim.status == 'active' %}
{{ claim.rights_holder.rights_holder_name }}
{% endif %}
{% endfor %}
, has agreed to release <i>{{work.title}}</i> to the world as a Creative Commons licensed ebook (<a href="{{ work.last_campaign.license_url }}">{{ work.last_campaign.license }}</a>) thanks to the efforts of ungluers like you.</p>
<h4>Campaign details: the fine print</h4>
{{ work.last_campaign.details|safe }}
{% endif %}
{% if status != 'ACTIVE' and status != 'SUCCESSFUL' %}
<h4> Rights Information </h4>
{% if claimstatus == 'one_active' %}
<p>This work has been claimed by {{ rights_holder_name }}.</p>
{% else %}
{% if claimstatus == 'one_pending' %}
<p>A claim for this work by {{ rights_holder_name }} is pending.</p>
{% if claimstatus == 'disputed' %}
<p>Rights claims are pending.</p>
{% else %}
{% if request.user.rights_holder.all.count %}
Is this work yours? Claim it: <br /><br />
{% if claimstatus == 'one_pending' %}
<p>A claim for this work by {{ rights_holder_name }} is pending.</p>
{% else %}
{% if request.user.rights_holder.all.count %}
Is this work yours? Claim it: <br /><br />
<form method="GET" action="{% url claim %}">
{% csrf_token %}
{{ claimform.user }}
{{ claimform.work }}
{{ claimform.rights_holder }}
<input type="submit" name="submit" value="Claim" />
</form><br />
<form method="GET" action="{% url claim %}">
{% csrf_token %}
{{ claimform.user }}
{{ claimform.work }}
{{ claimform.rights_holder }}
<input type="submit" name="submit" value="Claim" />
</form><br />
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
<p>If you'd like to contact us regarding rights for this work, please email <a href="mailto:rights@gluejar.com">rights@gluejar.com</a>.</p>
{% if work.first_ebook %}
<h4>Downloads</h4>
<div class="pledged-info">
This work has been downloaded {{ work.download_count }} times via unglue.it.
</div>
{% endif %}
{% if user.is_staff %}
<h4>Related Works</h4>
<div><a href="{% url merge work_id %}">Merge other works into this one</a></div>
<div><a href="{% url split work_id %}">Remove editions from this work</a><br /><br /></div>
{% endif %}
{% if work.subjects.all.count > 0 %}
<h4>Subjects</h4>
<ul>
{% for subject in work.subjects.all %}
<li itemprop="keywords">{{ subject.name }}</li>
{% endfor %}
</ul>
{% endif %}
<p>If you'd like to contact us regarding rights for this work, please email <a href="mailto:rights@gluejar.com">rights@gluejar.com</a>.</p>
{% if work.first_ebook %}
<h4>Downloads</h4>
<div class="pledged-info">
This work has been downloaded {{ work.download_count }} times via unglue.it ebook links.
</div>
{% endif %}
{% if user.is_staff %}
<h4>Related Works</h4>
<div><a href="{% url merge work_id %}">Merge other works into this one</a></div>
{% endif %}
{% if work.subjects.all.count > 0 %}
<h4>Subjects</h4>
<ul>
{% for subject in work.subjects.all %}
<li itemprop="keywords">{{ subject.name }}</li>
{% endfor %}
</ul>
{% endif %}
{% endifequal %}
<h4>Editions</h4>
{% if user.is_staff %}
{% if alert %}
<div class="yikes"><br />{{ alert }}</div>
{% endif %}
{% if user.is_staff or user in work.last_campaign.managers.all %}
<div><a href="{% url new_edition work_id edition.id %}">Create a new edition for this work</a><br /><br /></div>
{% endif %}
{% if alert %}
<div class="alert"><b>Ebook Contribution:</b><br />{{ alert }}</div>
{% endif %}
{% for edition in editions %}
<div class="clearfix">
<div class="editions">
{% if edition.googlebooks_id %}
<div class="image">
<img src="{{ edition.cover_image_small }}" title="edition cover" alt="edition cover" />
</div>
{% endif %}
<div class="metadata" id="edition_{{edition.id}}">
{% if edition.publisher %}
Publisher: <a href="{% url bypubname_list edition.publisher_name.id %}">{{edition.publisher}}</a><br />
{% endif %}
{% if edition.publication_date %}
Published: {{ edition.publication_date }}<br />
{% endif %}
{% if edition.isbn_13 %}
ISBN: <span itemprop="isbn">{{ edition.isbn_13 }}</span><br />
{% endif %}
{% if edition.oclc %}
OCLC: <a href="http://www.worldcat.org/oclc/{{ edition.oclc }}">{{ edition.oclc }}</a><br />
{% endif %}
{% if user.is_staff %}
<a href="{% url new_edition work_id edition.id %}">Edit this edition</a><br />
{% endif %}
{% if edition.googlebooks_id %}
See <a href="https://encrypted.google.com/books?id={{ edition.googlebooks_id }}">this edition on Google Books</a><br />
{% endif %}
{% for record in edition.MARCrecords.all %}
Download {{record.link_target}} MARC record for this edition: (<a href="{% url marc_concatenate %}?record_{{ record.id }}=on&amp;format=xml">XML</a>) (<a href="{% url marc_concatenate %}?record_{{ record.id }}=on&amp;format=mrc">mrc</a>)<br />
{% endfor %}
{% if user.is_staff %}{% if edition.ebooks.count or edition.ebook_files.count %}
<a href="{% url MARCUngluify %}?edition={{ edition.id }}">Upload</a> a MARC record for this edition. <br />
{% endif %} {% endif %}
</div>
</div>
{% if edition.ebook_form %}
{% ifnotequal status 'ACTIVE' %}
{% if edition.hide_details %}
<div class="show_more_edition" >
more...
</div>
{% endif %}
<div {% if edition.hide_details %} class="more_edition" {% endif %}>
{% if edition.ebooks.count %}
<h5>eBooks for this Edition</h5>
{% for ebook in edition.ebooks.all %}
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }}</a> {{ebook.rights}} at {{ebook.provider}}. Downloaded {{ ebook.download_count }} times.<br />
{% endfor %}
{% endif %}
<h5>Add an eBook for this Edition:</h5>
<span>If you know that this edition is available as a public domain or Creative Commons ebook, you can enter the link here and "unglue" it. Right now, we're only accepting URLs that point to Internet Archive, Wikisources, Hathitrust, Project Gutenberg, or Google Books.</span>
<form method="POST" action="#edition_{{edition.id}}">
{% csrf_token %}{{ edition.ebook_form.edition.errors }}{{ edition.ebook_form.edition }}{{ edition.ebook_form.user.errors }}{{ edition.ebook_form.user }}{{ edition.ebook_form.provider.errors }}{{ edition.ebook_form.provider }}
{{ edition.ebook_form.url.errors }}<span>URL: {{ edition.ebook_form.url }}</span><br />
{{ edition.ebook_form.format.errors }}<span>File Format: {{ edition.ebook_form.format }}</span>&nbsp;&nbsp;&nbsp;
{{ edition.ebook_form.rights.errors }}<span>License: {{ edition.ebook_form.rights }}</span><br />
<input type="submit" name="add_ebook" value="add ebook" />
</form>
</div>
{% ifequal action 'editions' %}
{% include 'split.html' %}
{% else %}
{% with work.preferred_edition as edition %}
{% include 'edition_display.html' %}
{% endwith %}
{% if not campaign %}
{% for edition in editions %}
{% ifnotequal edition work.preferred_edition %}
{% include 'edition_display.html' %}
{% endifnotequal %}
{% endif %}
</div>
{% endfor %}
{% endfor %}
{% endif %}
<div><a href="{% url work_editions work_id %}">All editions for this work/Add ebook links</a></div>
{% endifequal %}
</div>
</div>
</div>

View File

@ -95,7 +95,7 @@ urlpatterns = patterns(
url(r"^work/(?P<work_id>\d+)/borrow/$", "borrow", name="borrow"),
url(r"^work/(?P<work_id>\d+)/reserve/$", "reserve", name="reserve"),
url(r"^work/(?P<work_id>\d+)/merge/$", login_required(MergeView.as_view()), name="merge"),
url(r"^work/(?P<work_id>\d+)/split/$", "split_work", name="split"),
url(r"^work/(?P<work_id>\d+)/editions/$", "work",{'action': 'editions'}, name="work_editions"),
url(r"^work/\d+/acks/images/(?P<file_name>[\w\.]*)$", "static_redirect_view",{'dir': 'images'}),
url(r"^work/(?P<work_id>\d+)/librarything/$", "work_librarything", name="work_librarything"),
url(r"^work/(?P<work_id>\d+)/goodreads/$", "work_goodreads", name="work_goodreads"),

View File

@ -317,9 +317,29 @@ def social_auth_reset_password(request):
def work(request, work_id, action='display'):
work = safe_get_work(work_id)
alert=''
formset = None
if action == "acks":
return acks( request, work)
elif action == "editions":
EditionFormSet = inlineformset_factory(models.Work, models.Edition, fields=(), extra=0 )
if request.method == "POST" and (request.user.is_staff or user in work.last_campaign().managers.all()):
formset = EditionFormSet(data=request.POST, instance=work)
if formset.is_valid():
for form in formset.deleted_forms:
detach_edition(form.instance)
alert = 'editions have been split'
if request.POST.has_key('select_edition'):
selected_id=request.POST['select_edition']
try:
work.selected_edition= work.editions.get(id=selected_id)
work.save()
alert = alert + 'edition selected'
except models.Edition.DoesNotExist:
pass
formset = EditionFormSet(instance=work)
# process waiting add request
if not request.user.is_anonymous() and request.session.has_key("add_wishlist"):
add_url = request.session["add_wishlist"]
@ -331,6 +351,8 @@ def work(request, work_id, action='display'):
if request.method == 'POST' and not request.user.is_anonymous():
activetab = '4'
elif action == 'editions':
activetab = '4'
else:
try:
activetab = request.GET['tab']
@ -339,12 +361,8 @@ def work(request, work_id, action='display'):
except:
activetab = '1';
alert=''
campaign = work.last_campaign()
if campaign and campaign.edition and not request.user.is_staff:
editions = [campaign.edition]
else:
editions = work.editions.all().order_by('-publication_date')
editions = work.editions.all().order_by('-publication_date')[:10]
try:
pledged = campaign.transactions().filter(user=request.user, status="ACTIVE")
except:
@ -360,20 +378,6 @@ def work(request, work_id, action='display'):
if not request.user.is_anonymous():
claimform = UserClaimForm( request.user, data={'claim-work':work.pk, 'claim-user': request.user.id}, prefix = 'claim')
for edition in editions:
edition.hide_details = 1
if request.method == 'POST' and not request.user.is_anonymous():
if request.POST.has_key('ebook_%d-edition' % edition.id):
edition.ebook_form= EbookForm( data = request.POST, prefix = 'ebook_%d'%edition.id)
if edition.ebook_form.is_valid():
edition.ebook_form.save()
alert = 'Thanks for adding an ebook to unglue.it!'
else:
edition.hide_details = 0
alert = 'your submitted ebook had errors'
else:
#edition.ebook_form = EbookForm( data = {'user':request.user.id, 'edition':edition.pk })
edition.ebook_form = EbookForm( instance= models.Ebook(user = request.user, edition = edition, provider = 'x' ), prefix = 'ebook_%d'%edition.id)
else:
claimform = None
@ -418,6 +422,7 @@ def work(request, work_id, action='display'):
'rights_holder_name': rights_holder_name,
'cover_width': cover_width_number,
'action': action,
'formset': formset,
})
def edition_uploads(request, edition_id):
@ -470,7 +475,7 @@ def edition_uploads(request, edition_id):
})
return render(request, 'edition_uploads.html', context )
@login_required
def new_edition(request, work_id, edition_id, by=None):
if not request.user.is_authenticated() :
return render(request, "admins_only.html")
@ -485,13 +490,14 @@ def new_edition(request, work_id, edition_id, by=None):
title=work.title
else:
work=None
if not request.user.is_staff :
if by == 'rh' and work is not None:
if not request.user in work.last_campaign().managers.all():
return render(request, "admins_only.html")
else:
return render(request, "admins_only.html")
alert = ''
admin = False
if request.user.is_staff :
admin = True
elif work and work.last_campaign():
if request.user in work.last_campaign().managers.all():
admin = True
if edition_id:
try:
edition = models.Edition.objects.get(id = edition_id)
@ -505,18 +511,29 @@ def new_edition(request, work_id, edition_id, by=None):
edition = models.Edition()
if work:
edition.work = work
initial={
'language':language,
'publisher_name':edition.publisher_name,
'isbn':edition.isbn_13,
'oclc':edition.oclc,
'description':description,
'title': title,
'goog': edition.googlebooks_id,
'gdrd': edition.goodreads_id,
'thng': edition.librarything_id,
}
if request.method == 'POST' :
form = None
edition.new_author_names=request.POST.getlist('new_author')
edition.new_subjects=request.POST.getlist('new_subject')
if edition.id:
if edition.id and admin:
for author in edition.authors.all():
if request.POST.has_key('delete_author_%s' % author.id):
edition.authors.remove(author)
form = EditionForm(instance=edition, data=request.POST, files=request.FILES)
break
if request.POST.has_key('add_author_submit'):
if request.POST.has_key('add_author_submit') and admin:
new_author_name = request.POST['add_author'].strip()
try:
author= models.Author.objects.get(name=new_author_name)
@ -524,7 +541,7 @@ def new_edition(request, work_id, edition_id, by=None):
author=models.Author.objects.create(name=new_author_name)
edition.new_author_names.append(new_author_name)
form = EditionForm(instance=edition, data=request.POST, files=request.FILES)
elif request.POST.has_key('add_subject_submit'):
elif request.POST.has_key('add_subject_submit') and admin:
new_subject = request.POST['add_subject'].strip()
try:
author= models.Subject.objects.get(name=new_subject)
@ -532,7 +549,17 @@ def new_edition(request, work_id, edition_id, by=None):
author=models.Subject.objects.create(name=new_subject)
edition.new_subjects.append(new_subject)
form = EditionForm(instance=edition, data=request.POST, files=request.FILES)
elif not form:
edition.ebook_form = EbookForm( instance= models.Ebook(user = request.user, edition = edition, provider = 'x' ), prefix = 'ebook_%d'%edition.id)
elif request.POST.has_key('ebook_%d-edition' % edition.id):
edition.ebook_form= EbookForm( data = request.POST, prefix = 'ebook_%d'%edition.id)
if edition.ebook_form.is_valid():
edition.ebook_form.save()
alert = 'Thanks for adding an ebook to unglue.it!'
else:
alert = 'your submitted ebook had errors'
form = EditionForm(instance=edition, initial=initial)
elif not form and admin:
form = EditionForm(instance=edition, data=request.POST, files=request.FILES)
if form.is_valid():
form.save()
@ -544,6 +571,7 @@ def new_edition(request, work_id, edition_id, by=None):
else:
work.description=form.cleaned_data['description']
work.title=form.cleaned_data['title']
work.earliest_publication = None # will reset on next access
work.save()
id_msg=""
@ -585,20 +613,16 @@ def new_edition(request, work_id, edition_id, by=None):
edition.save()
return HttpResponseRedirect(work_url)
else:
form = EditionForm(instance=edition, initial={
'language':language,
'publisher_name':edition.publisher_name,
'isbn':edition.isbn_13,
'oclc':edition.oclc,
'description':description,
'title': title,
'goog': edition.googlebooks_id,
'gdrd': edition.goodreads_id,
'thng': edition.librarything_id,
})
if edition.pk:
edition.ebook_form = EbookForm( instance= models.Ebook(user = request.user, edition = edition, provider = 'x' ), prefix = 'ebook_%d'%edition.id)
form = EditionForm(instance=edition, initial=initial)
try:
show_ebook_form = edition.work.last_campaign().status not in ['ACTIVE','INITIALIZED']
except:
show_ebook_form = True
return render(request, 'new_edition.html', {
'form': form, 'edition': edition,
'form': form, 'edition': edition, 'admin':admin, 'alert':alert,
'show_ebook_form':show_ebook_form,
})
def campaign_results(request, campaign):
@ -645,6 +669,9 @@ def manage_campaign(request, id, action='manage'):
for offer in offers:
offer.offer_form=OfferForm(instance=offer,prefix='offer_%d'%offer.id)
campaign.update_left()
if campaign.type is THANKS :
campaign.work.description = form.cleaned_data['work_description']
campaign.work.save()
alerts.append(_('Campaign data has been saved'))
activetab = '#2'
else:
@ -684,7 +711,7 @@ def manage_campaign(request, id, action='manage'):
new_premium_form = CustomPremiumForm(data={'campaign': campaign})
activetab = '#2'
else:
form = getManageCampaignForm(instance=campaign)
form = getManageCampaignForm(instance=campaign, initial={'work_description':campaign.work.description})
new_premium_form = CustomPremiumForm(data={'campaign': campaign})
return render(request, 'manage_campaign.html', {
@ -924,22 +951,6 @@ class CampaignListView(FilterableListView):
context['facet'] =self.kwargs['facet']
return context
@login_required
def split_work(request,work_id):
if not request.user.is_staff:
return render(request, "admins_only.html")
work = safe_get_work(work_id)
EditionFormSet = inlineformset_factory(models.Work, models.Edition, fields=(), extra=0 )
if request.method == "POST":
formset = EditionFormSet(data=request.POST, instance=work)
if formset.is_valid():
for form in formset.deleted_forms:
detach_edition(form.instance)
formset = EditionFormSet(instance=work)
return render(request, "split.html", { "work":work, "formset": formset,})
class MergeView(FormView):
template_name="merge.html"
work=None