From 1881660089db232e31111f296ef7d22d73d0c4b8 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Mar 2013 23:41:19 -0400 Subject: [PATCH 01/14] intoduce Publisher and PublisherName Models Also change our by publisher lists to key on the new name ids rather than the names, which was yucky. Migrations! Data migration takes a while, don't be allarmed if it sits a while. --- admin.py | 8 +- core/bookloader.py | 4 +- core/fixtures/basic_campaign_test.json | 27 +- ...blisher__add_field_campaign_email__add_.py | 294 ++++++++++++++++++ core/migrations/0044_pubname_to_model.py | 258 +++++++++++++++ .../0045_auto__del_field_edition_publisher.py | 252 +++++++++++++++ core/models.py | 35 ++- core/sitemaps.py | 4 +- frontend/templates/work.html | 2 +- frontend/urls.py | 4 +- frontend/views.py | 21 +- 11 files changed, 891 insertions(+), 18 deletions(-) create mode 100644 core/migrations/0043_auto__add_publishername__add_publisher__add_field_campaign_email__add_.py create mode 100644 core/migrations/0044_pubname_to_model.py create mode 100644 core/migrations/0045_auto__del_field_edition_publisher.py diff --git a/admin.py b/admin.py index f1f224f3..8cf218b1 100644 --- a/admin.py +++ b/admin.py @@ -47,10 +47,15 @@ class SubjectAdmin(ModelAdmin): ordering = ('name',) class EditionAdmin(ModelAdmin): - list_display = ('title', 'publisher', 'created') + list_display = ('title', 'publisher_name', 'created') date_hierarchy = 'created' ordering = ('title',) +class PublisherAdmin(ModelAdmin): + list_display = ('name', 'url', 'logo_url', 'description') + date_hierarchy = 'created' + ordering = ('name',) + class EbookAdmin(ModelAdmin): date_hierarchy = 'created' ordering = ('edition__title',) @@ -91,6 +96,7 @@ admin_site.register(models.RightsHolder, RightsHolderAdmin) admin_site.register(models.Premium, PremiumAdmin) admin_site.register(models.Campaign, CampaignAdmin) admin_site.register(models.Author, AuthorAdmin) +admin_site.register(models.Publisher, PublisherAdmin) admin_site.register(models.Subject, SubjectAdmin) admin_site.register(models.Edition, EditionAdmin) admin_site.register(models.Ebook, EbookAdmin) diff --git a/core/bookloader.py b/core/bookloader.py index a14e224c..db976300 100755 --- a/core/bookloader.py +++ b/core/bookloader.py @@ -189,8 +189,8 @@ def update_edition(edition): # update the edition edition.title = title - edition.publisher = d.get('publisher') edition.publication_date = d.get('publishedDate', '') + edition.set_publisher(d.get('publisher')) edition.save() # create identifier if needed @@ -330,8 +330,8 @@ def add_by_googlebooks_id(googlebooks_id, work=None, results=None, isbn=None): # because this is a new google id, we have to create a new edition e = models.Edition(work=work) e.title = title - e.publisher = d.get('publisher') e.publication_date = d.get('publishedDate', '') + e.set_publisher(d.get('publisher')) e.save() e.new = True diff --git a/core/fixtures/basic_campaign_test.json b/core/fixtures/basic_campaign_test.json index aaa8a392..dc590228 100644 --- a/core/fixtures/basic_campaign_test.json +++ b/core/fixtures/basic_campaign_test.json @@ -285,11 +285,18 @@ "created": "2012-10-14T10:01:54" } }, + { + "pk": 1, + "model": "core.publishername", + "fields": { + "name": "Apress" + } + }, { "pk": 1, "model": "core.edition", "fields": { - "publisher": "Apress", + "publisher_name": 1, "title": "Pro Web 2.0 Mashups", "work": 1, "created": "2012-10-12T23:27:53", @@ -299,11 +306,18 @@ "unglued": false } }, + { + "pk": 2, + "model": "core.publishername", + "fields": { + "name": "Scribner" + } + }, { "pk": 2, "model": "core.edition", "fields": { - "publisher": "Scribner", + "publisher_name": 2, "title": "Moby Dick", "work": 2, "created": "2012-10-14T09:54:17", @@ -313,11 +327,18 @@ "unglued": false } }, + { + "pk": 3, + "model": "core.publishername", + "fields": { + "name": "Courier Dover Publications" + } + }, { "pk": 3, "model": "core.edition", "fields": { - "publisher": "Courier Dover Publications", + "publisher_name": 3, "title": "Mass in B Minor in Full Score", "work": 3, "created": "2012-10-14T10:01:54", diff --git a/core/migrations/0043_auto__add_publishername__add_publisher__add_field_campaign_email__add_.py b/core/migrations/0043_auto__add_publishername__add_publisher__add_field_campaign_email__add_.py new file mode 100644 index 00000000..c56cfcf3 --- /dev/null +++ b/core/migrations/0043_auto__add_publishername__add_publisher__add_field_campaign_email__add_.py @@ -0,0 +1,294 @@ +# -*- 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 model 'PublisherName' + db.create_table('core_publishername', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)), + ('publisher', self.gf('django.db.models.fields.related.ForeignKey')(related_name='all_names', null=True, to=orm['core.Publisher'])), + )) + db.send_create_signal('core', ['PublisherName']) + + # Adding model 'Publisher' + db.create_table('core_publisher', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)), + ('name', self.gf('django.db.models.fields.related.ForeignKey')(related_name='key_publisher', to=orm['core.PublisherName'])), + ('url', self.gf('django.db.models.fields.URLField')(max_length=1024, null=True)), + ('logo_url', self.gf('django.db.models.fields.URLField')(max_length=1024, null=True)), + ('description', self.gf('django.db.models.fields.TextField')(default='', null=True)), + )) + db.send_create_signal('core', ['Publisher']) + + # Adding field 'Campaign.email' + db.add_column('core_campaign', 'email', + self.gf('django.db.models.fields.CharField')(default='', max_length=100, blank=True), + keep_default=False) + + # Adding field 'Campaign.publisher' + db.add_column('core_campaign', 'publisher', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='campaigns', null=True, to=orm['core.Publisher']), + keep_default=False) + + # Adding field 'Edition.publisher_name' + db.add_column('core_edition', 'publisher_name', + self.gf('django.db.models.fields.related.ForeignKey')(related_name='editions', null=True, to=orm['core.PublisherName']), + keep_default=False) + + + def backwards(self, orm): + # Deleting model 'PublisherName' + db.delete_table('core_publishername') + + # Deleting model 'Publisher' + db.delete_table('core_publisher') + + # Deleting field 'Campaign.email' + db.delete_column('core_campaign', 'email') + + # Deleting field 'Campaign.publisher' + db.delete_column('core_campaign', 'publisher_id') + + # Deleting field 'Edition.publisher_name' + db.delete_column('core_edition', 'publisher_name_id') + + + 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.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'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'deadline': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), + 'description': ('ckeditor.fields.RichTextField', [], {'null': 'True'}), + 'details': ('ckeditor.fields.RichTextField', [], {'null': 'True', 'blank': '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', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}), + '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(2013, 3, 25, 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'}), + '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.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'}), + 'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}), + 'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'publisher': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', '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.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.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.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'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'logo_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': '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'}) + }, + 'core.publishername': { + 'Meta': {'object_name': 'PublisherName'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}), + 'publisher': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'all_names'", 'null': 'True', 'to': "orm['core.Publisher']"}) + }, + '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'}) + }, + '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', [], {'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'}), + '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'}), + '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'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) + } + } + + complete_apps = ['core'] \ No newline at end of file diff --git a/core/migrations/0044_pubname_to_model.py b/core/migrations/0044_pubname_to_model.py new file mode 100644 index 00000000..b5c3408c --- /dev/null +++ b/core/migrations/0044_pubname_to_model.py @@ -0,0 +1,258 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import DataMigration +from django.db import models + +class Migration(DataMigration): + + def forwards(self, orm): + for edition in orm.Edition.objects.all(): + if edition.publisher and edition.publisher != '': + try: + pub_name = orm.PublisherName.objects.get(name=edition.publisher) + except orm.PublisherName.DoesNotExist: + pub_name = orm.PublisherName.objects.create(name=edition.publisher) + pub_name.save() + edition.publisher_name = pub_name + edition.save() + + def backwards(self, orm): + for edition in orm.Edition.objects.all(): + if edition.publisher_name: + edition.publisher = edition.publisher_name.name + edition.save() + + 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.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'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'deadline': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), + 'description': ('ckeditor.fields.RichTextField', [], {'null': 'True'}), + 'details': ('ckeditor.fields.RichTextField', [], {'null': 'True', 'blank': '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', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}), + '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(2013, 3, 25, 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'}), + '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.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'}), + 'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': 'True'}), + 'publication_date': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'publisher': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', '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.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.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.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'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'logo_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': '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'}) + }, + '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': "'all_names'", 'null': 'True', 'to': "orm['core.Publisher']"}) + }, + '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'}) + }, + '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', [], {'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'}), + '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'}), + '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'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) + } + } + + complete_apps = ['core'] + symmetrical = True diff --git a/core/migrations/0045_auto__del_field_edition_publisher.py b/core/migrations/0045_auto__del_field_edition_publisher.py new file mode 100644 index 00000000..d25d2c0c --- /dev/null +++ b/core/migrations/0045_auto__del_field_edition_publisher.py @@ -0,0 +1,252 @@ +# -*- 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): + # Deleting field 'Edition.publisher' + db.delete_column('core_edition', 'publisher') + + + def backwards(self, orm): + # Adding field 'Edition.publisher' + db.add_column('core_edition', 'publisher', + self.gf('django.db.models.fields.CharField')(blank=True, max_length=255, null=True, db_index=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'}) + }, + '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.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'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'deadline': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), + 'description': ('ckeditor.fields.RichTextField', [], {'null': 'True'}), + 'details': ('ckeditor.fields.RichTextField', [], {'null': 'True', 'blank': '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', [], {'null': 'True', 'max_digits': '14', 'decimal_places': '2'}), + '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(2013, 3, 25, 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'}), + '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.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'}), + 'public_domain': ('django.db.models.fields.NullBooleanField', [], {'null': 'True', 'blank': '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.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.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.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'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'logo_url': ('django.db.models.fields.URLField', [], {'max_length': '1024', 'null': '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'}) + }, + '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': "'all_names'", 'null': 'True', 'to': "orm['core.Publisher']"}) + }, + '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'}) + }, + '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', [], {'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'}), + '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'}), + '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'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '1000'}) + } + } + + complete_apps = ['core'] \ No newline at end of file diff --git a/core/models.py b/core/models.py index e7c7d105..993738fc 100755 --- a/core/models.py +++ b/core/models.py @@ -227,6 +227,8 @@ class Campaign(models.Model): # status: INITIALIZED, ACTIVE, SUSPENDED, WITHDRAWN, SUCCESSFUL, UNSUCCESSFUL status = models.CharField(max_length=15, null=True, blank=False, default="INITIALIZED") edition = models.ForeignKey("Edition", related_name="campaigns", null=True) + email = models.CharField(max_length=100, blank=True) + publisher = models.ForeignKey("Publisher", related_name="campaigns", null=True) problems = [] def __unicode__(self): @@ -869,7 +871,7 @@ class Subject(models.Model): class Edition(models.Model): created = models.DateTimeField(auto_now_add=True) title = models.CharField(max_length=1000) - publisher = models.CharField(max_length=255, null=True, blank=True, db_index=True) + 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) @@ -901,7 +903,12 @@ class Edition(models.Model): return "https://encrypted.google.com/books?id=%s&printsec=frontcover&img=1&zoom=1" % self.googlebooks_id else: return '' - + @property + def publisher(self): + if self.publisher_name: + return self.publisher_name.name + return '' + @property def isbn_10(self): return regluit.core.isbn.convert_13_to_10(self.isbn_13) @@ -949,6 +956,30 @@ class Edition(models.Model): return Identifier.objects.get( type='isbn', value=isbn ).edition except Identifier.DoesNotExist: return None + + def set_publisher(self,publisher_name): + if publisher_name and publisher_name != '': + try: + pub_name = PublisherName.objects.get(name=publisher_name) + except PublisherName.DoesNotExist: + pub_name = PublisherName.objects.create(name=publisher_name) + pub_name.save() + self.publisher_name = pub_name + self.save() + +class Publisher(models.Model): + created = models.DateTimeField(auto_now_add=True) + name = models.ForeignKey('PublisherName', related_name='key_publisher') + url = models.URLField(max_length=1024, null=True) + logo_url = models.URLField(max_length=1024, null=True) + description = models.TextField(default='', null=True) + +class PublisherName(models.Model): + name = models.CharField(max_length=255, blank=False) + publisher = models.ForeignKey('Publisher', related_name='all_names', null=True) + + def __unicode__(self): + return self.name class WasWork(models.Model): work = models.ForeignKey('Work') diff --git a/core/sitemaps.py b/core/sitemaps.py index b676d79d..c92f8672 100644 --- a/core/sitemaps.py +++ b/core/sitemaps.py @@ -31,7 +31,7 @@ class PublisherSitemap(Sitemap): protocol = 'https' def items(self): - return Edition.objects.exclude(publisher__isnull=True).exclude(publisher="").order_by('publisher').values('publisher').distinct() + return Edition.objects.exclude(publisher_name__isnull=True).order_by('publisher_name__name').values('publisher_name').distinct() def location(self, pub): - return reverse("bypub_list",args=[pub['publisher']]) + return reverse("bypubname_list",args=[pub['publisher_name']]) diff --git a/frontend/templates/work.html b/frontend/templates/work.html index d8f4afc0..9dcfa196 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -338,7 +338,7 @@ {% endif %}
{% if edition.publisher %} - Publisher: {{edition.publisher}}
+ Publisher: {{edition.publisher}}
{% endif %} {% if edition.publication_date %} Published: {{ edition.publication_date }}
diff --git a/frontend/urls.py b/frontend/urls.py index 1224589f..ac9f8c24 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -11,7 +11,7 @@ from regluit.core.feeds import SupporterWishlistFeed from regluit.core.models import Campaign from regluit.frontend.views import GoodreadsDisplayView, LibraryThingView, PledgeView, PledgeCompleteView, PledgeCancelView, PledgeRechargeView, FAQView from regluit.frontend.views import CampaignListView, WorkListView, UngluedListView, InfoPageView, InfoLangView, DonationView, FundPledgeView -from regluit.frontend.views import NonprofitCampaign, DonationCredit, PledgeModifiedView, ManageAccount, MergeView, ByPubListView +from regluit.frontend.views import NonprofitCampaign, DonationCredit, PledgeModifiedView, ManageAccount, MergeView, ByPubListView, ByPubView urlpatterns = patterns( "regluit.frontend.views", @@ -39,6 +39,8 @@ urlpatterns = patterns( url(r"^msg/$", "msg", name="msg"), url(r"^campaigns/(?P\w*)$", CampaignListView.as_view(), name='campaign_list'), url(r"^lists/(?P\w*)$", WorkListView.as_view(), name='work_list'), + url(r"^pid/all/(?P\d+)$", ByPubView.as_view(), name='bypubname_list'), + url(r"^pid/(?P\w*)/(?P\d+)$", ByPubView.as_view(), name='bypubname_list'), url(r"^bypub/all/(?P.*)$", ByPubListView.as_view(), name='bypub_list'), url(r"^bypub/(?P\w*)/(?P.*)$", ByPubListView.as_view(), name='bypub_list'), url(r"^unglued/(?P\w*)$", UngluedListView.as_view(), name='unglued_list'), diff --git a/frontend/views.py b/frontend/views.py index ceae6f47..1a4879f0 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -521,15 +521,19 @@ class WorkListView(FilterableListView): return context -class ByPubListView(WorkListView): +class ByPubView(WorkListView): template_name = "bypub_list.html" context_object_name = "work_list" max_works=100000 - + publisher_name=None + + def get_publisher_name(self): + self.publisher_name = get_object_or_404(models.PublisherName, id=self.kwargs['pubname']) + def get_queryset_all(self): facet = self.kwargs.get('facet','') - pubname = self.kwargs['pubname'] - objects = models.Work.objects.filter(editions__publisher__iexact=pubname).distinct() + self.get_publisher_name() + objects = models.Work.objects.filter(editions__publisher_name__id=self.publisher_name.id).distinct() if (facet == 'popular'): return objects.order_by('-num_wishes', 'id') elif (facet == 'pubdate'): @@ -540,10 +544,15 @@ class ByPubListView(WorkListView): return objects.order_by('title', 'id') def get_context_data(self, **kwargs): - context = super(ByPubListView, self).get_context_data(**kwargs) - context['pubname'] = self.kwargs['pubname'] + context = super(ByPubView, self).get_context_data(**kwargs) + context['pubname'] = self.publisher_name return context +class ByPubListView(ByPubView): + def get_publisher_name(self): + self.publisher_name = get_object_or_404(models.PublisherName, name=self.kwargs['pubname']) + + class UngluedListView(FilterableListView): template_name = "unglued_list.html" context_object_name = "work_list" From 90d01894d2b5b0bde05d90c9f926e166da420ed1 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 25 Mar 2013 23:41:59 -0400 Subject: [PATCH 02/14] don't ask people to add books by publisher --- frontend/templates/bypub_list.html | 2 ++ frontend/templates/work_list.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/templates/bypub_list.html b/frontend/templates/bypub_list.html index 095eca00..d2d868eb 100644 --- a/frontend/templates/bypub_list.html +++ b/frontend/templates/bypub_list.html @@ -6,3 +6,5 @@ {% block userblock2 %} Books from {{ pubname }} {% if pub_lang %}( {{pub_lang|ez_lang_name}} ) {% endif %} {% endblock %} + +{% block add_more %}{% endblock %} \ No newline at end of file diff --git a/frontend/templates/work_list.html b/frontend/templates/work_list.html index 85459dbf..60a39756 100644 --- a/frontend/templates/work_list.html +++ b/frontend/templates/work_list.html @@ -81,7 +81,7 @@
{% ifequal work_list.count 0 %} {% block noworks %} - There aren't any {{ pub_lang|ez_lang_name }} works in this list yet. Why not add your favorite books to your wishlist, so we can feature them here? + There aren't any {{ pub_lang|ez_lang_name }} works in this list yet. {% block add_more %}Why not add your favorite books to your wishlist, so we can feature them here?{% endblock %} {% endblock %} {% else %} {% lazy_paginate 20 works_unglued using "works_unglued" %} From 3bef92b4841ed21242b3808fa53e60767332b9d1 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 26 Mar 2013 10:56:49 -0400 Subject: [PATCH 03/14] Publishers can now be added in Admin --- admin.py | 23 ++++++++++++++++++++--- core/lookups.py | 10 +++++++--- frontend/templates/admin/base_site.html | 16 ++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 frontend/templates/admin/base_site.html diff --git a/admin.py b/admin.py index 8cf218b1..c22d74f2 100644 --- a/admin.py +++ b/admin.py @@ -1,9 +1,14 @@ +from django import forms from django.contrib.auth.models import User from django.contrib.admin import ModelAdmin from django.contrib.admin.sites import AdminSite +from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField + + from regluit.core import models from regluit import payment +from regluit.core.lookups import PublisherNameLookup from djcelery.admin import TaskState, WorkerState, TaskMonitor, WorkerMonitor, \ IntervalSchedule, CrontabSchedule, PeriodicTask, PeriodicTaskAdmin @@ -51,11 +56,23 @@ class EditionAdmin(ModelAdmin): date_hierarchy = 'created' ordering = ('title',) +class PublisherAdminForm(forms.ModelForm): + name = AutoCompleteSelectField( + PublisherNameLookup, + label='Name', + widget=AutoCompleteSelectWidget(PublisherNameLookup), + required=True, + ) + + class Meta(object): + model = models.Publisher + + class PublisherAdmin(ModelAdmin): list_display = ('name', 'url', 'logo_url', 'description') - date_hierarchy = 'created' ordering = ('name',) - + form = PublisherAdminForm + class EbookAdmin(ModelAdmin): date_hierarchy = 'created' ordering = ('edition__title',) @@ -89,7 +106,7 @@ class NoticeQueueBatchAdmin(ModelAdmin): admin_site = RegluitAdmin("Admin") -admin_site.register(models.User, UserAdmin) +admin_site.register(User, UserAdmin) admin_site.register(models.Work, WorkAdmin) admin_site.register(models.Claim, ClaimAdmin) admin_site.register(models.RightsHolder, RightsHolderAdmin) diff --git a/core/lookups.py b/core/lookups.py index 0eb2dbea..4c073651 100644 --- a/core/lookups.py +++ b/core/lookups.py @@ -2,7 +2,7 @@ from selectable.base import ModelLookup from selectable.registry import registry from django.contrib.auth.models import User -from regluit.core.models import Work +from regluit.core.models import Work, PublisherName class OwnerLookup(ModelLookup): model = User @@ -21,6 +21,10 @@ class WorkLookup(ModelLookup): results = results.filter(language=language) return results - +class PublisherNameLookup(ModelLookup): + model = PublisherName + search_fields = ('name__icontains',) + registry.register(OwnerLookup) -registry.register(WorkLookup) \ No newline at end of file +registry.register(WorkLookup) +registry.register(PublisherNameLookup) \ No newline at end of file diff --git a/frontend/templates/admin/base_site.html b/frontend/templates/admin/base_site.html new file mode 100644 index 00000000..e1143615 --- /dev/null +++ b/frontend/templates/admin/base_site.html @@ -0,0 +1,16 @@ +{% extends "admin/base.html" %} +{% load i18n %} + +{% block title %}{{ title }} | {% trans 'Django site admin' %}{% endblock %} + +{% block branding %} +

{% trans 'Django administration' %}

+{% endblock %} + +{% block nav-global %}{% endblock %} + +{% block extrahead %} + {% load selectable_tags %} + {% include_ui_theme %} + {% include_jquery_libs %} +{% endblock %} From 782f2bd7121cef8c5f41e98f126afae7c2967f34 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 26 Mar 2013 14:12:58 -0400 Subject: [PATCH 04/14] can now admin the publishernames. Setting a publisher moves the editions to that publisher's name --- admin.py | 7 ++++++- core/models.py | 14 ++++++++++++++ .../admin/core/publishername/change_form.html | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 frontend/templates/admin/core/publishername/change_form.html diff --git a/admin.py b/admin.py index c22d74f2..64accf39 100644 --- a/admin.py +++ b/admin.py @@ -66,12 +66,16 @@ class PublisherAdminForm(forms.ModelForm): class Meta(object): model = models.Publisher - class PublisherAdmin(ModelAdmin): list_display = ('name', 'url', 'logo_url', 'description') ordering = ('name',) form = PublisherAdminForm + +class PublisherNameAdmin(ModelAdmin): + list_display = ('name', 'publisher') + ordering = ('name',) + search_fields = ['name'] class EbookAdmin(ModelAdmin): date_hierarchy = 'created' @@ -114,6 +118,7 @@ admin_site.register(models.Premium, PremiumAdmin) admin_site.register(models.Campaign, CampaignAdmin) admin_site.register(models.Author, AuthorAdmin) admin_site.register(models.Publisher, PublisherAdmin) +admin_site.register(models.PublisherName, PublisherNameAdmin) admin_site.register(models.Subject, SubjectAdmin) admin_site.register(models.Edition, EditionAdmin) admin_site.register(models.Ebook, EbookAdmin) diff --git a/core/models.py b/core/models.py index 993738fc..95ac9102 100755 --- a/core/models.py +++ b/core/models.py @@ -974,12 +974,26 @@ class Publisher(models.Model): logo_url = models.URLField(max_length=1024, null=True) description = models.TextField(default='', null=True) + def __unicode__(self): + return self.name.name + class PublisherName(models.Model): name = models.CharField(max_length=255, blank=False) + + # all_names was a bad choice. should be "alternate_names" publisher = models.ForeignKey('Publisher', related_name='all_names', null=True) def __unicode__(self): return self.name + + def save(self, *args, **kwargs): + super(PublisherName, self).save(*args, **kwargs) # Call the "real" save() method. + if self.publisher and self != self.publisher.name: + #this name is an alias, repoint all editions with this name to the other. + for edition in Edition.objects.filter(publisher_name=self): + edition.publisher_name = self.publisher.name + edition.save() + class WasWork(models.Model): work = models.ForeignKey('Work') diff --git a/frontend/templates/admin/core/publishername/change_form.html b/frontend/templates/admin/core/publishername/change_form.html new file mode 100644 index 00000000..edc41e54 --- /dev/null +++ b/frontend/templates/admin/core/publishername/change_form.html @@ -0,0 +1,4 @@ +{% extends "admin/change_form.html" %} +{% block after_field_sets %} +

If you set a publisher for this publisher name, all the editions connected to this name will get attached to the publisher's name instead. ( Unless it's already set to this name!) +{% endblock %} \ No newline at end of file From 2b28add6a89838b208f91abd2f017ed16bdcecfd Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 26 Mar 2013 14:53:48 -0400 Subject: [PATCH 05/14] first pass at publisher page in admin created publisher "De Gruyter" url=http://degruyter.com/" logo_url=https://www.degruyter.com/skin/20130326/images/logo.png description=For more than two-hundred and sixty years the name De Gruyter has been synonymous with high-quality, landmark publications in the humanities and natural sciences. The scope of our publishing program includes theology and philosophy, biology and chemistry, linguistics and literature, mathematics and physics, history and archaeology, as well as law and medicine. In all these areas De Gruyter has consistently partnered with exceptional scholars to establish itself as a key international publisher. page at http://localhost:8000/bypub/all/de%20gruyter and http://localhost:8000/pid/all/4702 (my db pubname id for de gruyter is 4702) --- frontend/templates/bypub_list.html | 14 +++++++++++++- frontend/templates/work_list.html | 3 ++- frontend/views.py | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/templates/bypub_list.html b/frontend/templates/bypub_list.html index d2d868eb..178c09e6 100644 --- a/frontend/templates/bypub_list.html +++ b/frontend/templates/bypub_list.html @@ -3,8 +3,20 @@ {% load lang_utils %} {% block title %} Works published by {{ pubname }} {% endblock %} +{% block userblock1 %} + {% if publisher %} +

+ {% else %} + {{ block.super }} + {% endif %} +{% endblock %} {% block userblock2 %} -Books from {{ pubname }} {% if pub_lang %}( {{pub_lang|ez_lang_name}} ) {% endif %} + {% if publisher %} + Books from {{ pubname }} {% if pub_lang %}( {{pub_lang|ez_lang_name}} ) {% endif %} +
{{ publisher.description|safe }}
+ {% else %} + Books from {{ pubname }} {% if pub_lang %}( {{pub_lang|ez_lang_name}} ) {% endif %} +{% endif %} {% endblock %} {% block add_more %}{% endblock %} \ No newline at end of file diff --git a/frontend/templates/work_list.html b/frontend/templates/work_list.html index 60a39756..831b9757 100644 --- a/frontend/templates/work_list.html +++ b/frontend/templates/work_list.html @@ -27,7 +27,7 @@
{% block userblock %}
-
{{ facet|capfirst }}
+ {% block userblock1 %}
{{ facet|capfirst }}
{% endblock %}
{% block userblock2 %} @@ -35,6 +35,7 @@ {% endblock %}
+ {% block userblock3 %}{% endblock %}
{% endblock %}
diff --git a/frontend/views.py b/frontend/views.py index 1a4879f0..bf3e7a9b 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -524,11 +524,20 @@ class WorkListView(FilterableListView): class ByPubView(WorkListView): template_name = "bypub_list.html" context_object_name = "work_list" - max_works=100000 - publisher_name=None + max_works = 100000 + publisher_name = None + publisher = None def get_publisher_name(self): self.publisher_name = get_object_or_404(models.PublisherName, id=self.kwargs['pubname']) + self.set_publisher() + + def set_publisher(self): + if self.publisher_name.key_publisher: + self.publisher = self.publisher_name.key_publisher.all()[0] + elif self.publisher_name.publisher: + self.publisher = self.publisher_name.publisher + self.publisher_name = self.publisher.name def get_queryset_all(self): facet = self.kwargs.get('facet','') @@ -546,11 +555,13 @@ class ByPubView(WorkListView): def get_context_data(self, **kwargs): context = super(ByPubView, self).get_context_data(**kwargs) context['pubname'] = self.publisher_name + context['publisher'] = self.publisher return context class ByPubListView(ByPubView): def get_publisher_name(self): self.publisher_name = get_object_or_404(models.PublisherName, name=self.kwargs['pubname']) + self.set_publisher() class UngluedListView(FilterableListView): From 3a81db380474962e459afd112628ef56825fcdc9 Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 27 Mar 2013 12:22:30 -0400 Subject: [PATCH 06/14] Implement publisher and feedback email in campaign management (feedback view made more flexible) --- core/models.py | 10 +++-- frontend/forms.py | 3 +- frontend/templates/ask_rh.html | 34 ++++++++++++++ frontend/templates/ask_rh.txt | 4 ++ frontend/templates/feedback.txt | 5 +++ frontend/templates/manage_campaign.html | 15 ++++--- frontend/templates/work.html | 17 ++++++- frontend/urls.py | 1 + frontend/views.py | 60 +++++++++++++------------ 9 files changed, 111 insertions(+), 38 deletions(-) create mode 100644 frontend/templates/ask_rh.html create mode 100644 frontend/templates/ask_rh.txt create mode 100644 frontend/templates/feedback.txt diff --git a/core/models.py b/core/models.py index 95ac9102..3961eee0 100755 --- a/core/models.py +++ b/core/models.py @@ -847,6 +847,10 @@ class Work(models.Model): def get_absolute_url(self): return reverse('work', args=[str(self.id)]) + def publishers(self): + # returns a set of publishers associated with this Work + return Publisher.objects.filter(name__editions__work=self).distinct() + class Author(models.Model): created = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=500) @@ -970,9 +974,9 @@ class Edition(models.Model): class Publisher(models.Model): created = models.DateTimeField(auto_now_add=True) name = models.ForeignKey('PublisherName', related_name='key_publisher') - url = models.URLField(max_length=1024, null=True) - logo_url = models.URLField(max_length=1024, null=True) - description = models.TextField(default='', null=True) + url = models.URLField(max_length=1024, null=True, blank=True) + logo_url = models.URLField(max_length=1024, null=True, blank=True) + description = models.TextField(default='', null=True, blank=True) def __unicode__(self): return self.name.name diff --git a/frontend/forms.py b/frontend/forms.py index 9ac48114..6318680c 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -303,10 +303,11 @@ def getManageCampaignForm ( instance, data=None, *args, **kwargs ): edition = forms.ModelChoiceField(get_queryset(), widget=RadioSelect(),empty_label='no edition selected',required = False,) minimum_target = settings.UNGLUEIT_MINIMUM_TARGET latest_ending = (timedelta(days=int(settings.UNGLUEIT_LONGEST_DEADLINE)) + now()).date + publisher = forms.ModelChoiceField(instance.work.publishers(), empty_label='no publisher selected', required = False,) class Meta: model = Campaign - fields = 'description', 'details', 'license', 'target', 'deadline', 'paypal_receiver', 'edition' + fields = 'description', 'details', 'license', 'target', 'deadline', 'paypal_receiver', 'edition', 'email', 'publisher' widgets = { 'deadline': SelectDateWidget, } diff --git a/frontend/templates/ask_rh.html b/frontend/templates/ask_rh.html new file mode 100644 index 00000000..2ce66338 --- /dev/null +++ b/frontend/templates/ask_rh.html @@ -0,0 +1,34 @@ +{% extends "basedocumentation.html" %} + +{% block title %}Campaign questions{% endblock %} + +{% block doccontent %} +{% if campaign.email %} +

Questions about {{campaign}}? Ask away!

+ + To: {{campaign}}

+
+ {% csrf_token %} + {{ form.sender.errors }} + {{ form.sender.label_tag }}
+ {{ form.sender }}

+ {{ form.subject.errors }} + {{ form.subject.label_tag }}
+ {{ form.subject }}

+ {{ form.message.errors }} + {{ form.message.label_tag }}
+ {{ form.message }}

+ {{ form.notarobot.errors }} + {{ form.non_field_errors }} + Please prove you're not a robot. {{num1}} + {{num2}} = + {{ form.notarobot }}

+ {{ form.answer }} + {{ form.num1 }} + {{ form.num2 }} + {{ form.page }} + +
+{% else %} +

Sorry, this campaign isn't set up to answer emails at this time.

+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/frontend/templates/ask_rh.txt b/frontend/templates/ask_rh.txt new file mode 100644 index 00000000..fe9a1225 --- /dev/null +++ b/frontend/templates/ask_rh.txt @@ -0,0 +1,4 @@ +{{ sender }} has a question about {{campaign}} +_____________________________________ + +{{ message }} \ No newline at end of file diff --git a/frontend/templates/feedback.txt b/frontend/templates/feedback.txt new file mode 100644 index 00000000..ca1aed78 --- /dev/null +++ b/frontend/templates/feedback.txt @@ -0,0 +1,5 @@ +This feedback is about {{ page }} +From {{ sender }}, ungluer name {{ request.user.username }} +user agent {{ request.META.HTTP_USER_AGENT }} +_____________________________________ +{{ message }} \ No newline at end of file diff --git a/frontend/templates/manage_campaign.html b/frontend/templates/manage_campaign.html index d03c7ef2..9dac0f80 100644 --- a/frontend/templates/manage_campaign.html +++ b/frontend/templates/manage_campaign.html @@ -246,12 +246,17 @@ Please fix the following before launching your campaign: {{ form.deadline.errors }}{{ form.deadline }} {% endifnotequal %} -

e-mail contact address

-

Enter the email address where notifications about this campaign should be sent. If your campaign succeeds, this email needs to work if you want to get paid!

- - +

e-mail contact addresses

+

Enter the email address where notifications about this campaign should be sent. If your campaign succeeds, this email needs to work if you want to get paid! This address will not be exposed on the website.

{{ form.paypal_receiver.errors }}{{ form.paypal_receiver }}

- +

(Optional, but highly recommended). Enter an email address where ungluers with questions about the book or the campaign can contact you or someone involved. This address will not be exposed on the website.

+

{{ form.email.errors }}{{ form.email }}

+ + {% if work.publishers %} +

Publisher

+

If you are set up as an unglue.it publisher (send us a url, logo, description and list of ways your name might appear) you can link your campaign by selecting the publisher here: +

{{ form.publisher.errors }}{{ form.publisher }}

+ {% endif %} {% ifequal campaign_status 'ACTIVE' %}
When you click this button, your changes will be visible to supporters immediately. Make sure to proofread!

diff --git a/frontend/templates/work.html b/frontend/templates/work.html index 9dcfa196..a3b8ef72 100644 --- a/frontend/templates/work.html +++ b/frontend/templates/work.html @@ -73,7 +73,12 @@
- +

+ {% if work.last_campaign.publisher %} + {{ work.last_campaign.publisher }} + {% endif %} + +

@@ -412,6 +417,16 @@

+ {% ifequal status 'ACTIVE' %}{% if work.last_campaign.email %} +
+

Ask Questions

+ +
+ {% endif %}{% endifequal %}

Share

diff --git a/frontend/urls.py b/frontend/urls.py index ac9f8c24..bb70f23d 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -81,6 +81,7 @@ urlpatterns = patterns( url('^500testing/$', direct_to_template, {'template': '500.html'}), url('^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}), url(r"^emailshare/(?P\w*)/?$", "emailshare", name="emailshare"), + url(r"^feedback/campaign/(?P\d+)/?$", "ask_rh", name="ask_rh"), url(r"^feedback/$", "feedback", name="feedback"), url(r"^feedback/thanks/$", TemplateView.as_view(template_name="thanks.html")), url(r"^press/$", TemplateView.as_view(template_name="press.html"), diff --git a/frontend/views.py b/frontend/views.py index bf3e7a9b..9ab7e6be 100755 --- a/frontend/views.py +++ b/frontend/views.py @@ -533,7 +533,7 @@ class ByPubView(WorkListView): self.set_publisher() def set_publisher(self): - if self.publisher_name.key_publisher: + if self.publisher_name.key_publisher.count(): self.publisher = self.publisher_name.key_publisher.all()[0] elif self.publisher_name.publisher: self.publisher = self.publisher_name.publisher @@ -2131,45 +2131,49 @@ def emailshare(request, action): return render(request, "emailshare.html", {'form':form}) -def feedback(request): - num1 = randint(0,10) - num2 = randint(0,10) - sum = num1 + num2 +def ask_rh(request, campaign_id): + campaign = get_object_or_404(models.Campaign, id=campaign_id) + return feedback(request, recipient=campaign.email, template="ask_rh.html", + message_template="ask_rh.txt", + redirect_url = reverse('work', args=[campaign.work.id]), + extra_context={'campaign':campaign, 'subject':campaign }) + +def feedback(request, recipient='support@gluejar.com', template='feedback.html', message_template='feedback.txt', extra_context=None, redirect_url=None): + context = extra_context or {} + context['num1'] = randint(0,10) + context['num2'] = randint(0,10) + context['answer'] = context['num1'] + context['num2'] if request.method == 'POST': form=FeedbackForm(request.POST) if form.is_valid(): - subject = form.cleaned_data['subject'] - message = form.cleaned_data['message'] - sender = form.cleaned_data['sender'] - recipient = 'support@gluejar.com' - page = form.cleaned_data['page'] - useragent = request.META['HTTP_USER_AGENT'] - if request.user.is_anonymous(): - ungluer = "(not logged in)" + context.update(form.cleaned_data) + context['request']=request + if extra_context: + context.update(extra_context) + message = render_to_string(message_template,context) + send_mail_task.delay(context['subject'], message, context['sender'], [recipient]) + if redirect_url: + return HttpResponseRedirect(redirect_url) else: - ungluer = request.user.username - message = "<<>>\n"+message - send_mail_task.delay(subject, message, sender, [recipient]) - - return render(request, "thanks.html", {"page":page}) + return render(request, "thanks.html", context) else: - num1 = request.POST['num1'] - num2 = request.POST['num2'] + context['num1'] = request.POST['num1'] + context['num2'] = request.POST['num2'] else: if request.user.is_authenticated(): - sender=request.user.email; - else: - sender='' + context['sender']=request.user.email; try: - page = request.GET['page'] + context['page'] = request.GET['page'] except: - page='/' - form = FeedbackForm(initial={"sender":sender, "subject": "Feedback on page "+page, "page":page, "num1":num1, "num2":num2, "answer":sum}) - - return render(request, "feedback.html", {'form':form, 'num1':num1, 'num2':num2}) + context['page'] = '/' + if not context.has_key('subject'): + context['subject'] = "Feedback on page "+context['page'] + form = FeedbackForm(initial=context) + context['form'] = form + return render(request, template, context) def comment(request): latest_comments = Comment.objects.all().order_by('-submit_date')[:20] From 56691cd3e00574a50bc88f87f760c8aa8ff8a84a Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 27 Mar 2013 12:51:10 -0400 Subject: [PATCH 07/14] make sure alias pubname is used for new, add tests --- core/models.py | 2 ++ core/tests.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/models.py b/core/models.py index 3961eee0..6caf980a 100755 --- a/core/models.py +++ b/core/models.py @@ -965,6 +965,8 @@ class Edition(models.Model): if publisher_name and publisher_name != '': try: pub_name = PublisherName.objects.get(name=publisher_name) + if pub_name.publisher: + pub_name = pub_name.publisher.name except PublisherName.DoesNotExist: pub_name = PublisherName.objects.create(name=publisher_name) pub_name.save() diff --git a/core/tests.py b/core/tests.py index 04f5bd60..6878cefa 100755 --- a/core/tests.py +++ b/core/tests.py @@ -15,7 +15,7 @@ from django.contrib.sites.models import Site from django.http import Http404 from regluit.payment.models import Transaction -from regluit.core.models import Campaign, Work, UnglueitError, Edition, RightsHolder, Claim, Key, Ebook, Premium, Subject +from regluit.core.models import Campaign, Work, UnglueitError, Edition, RightsHolder, Claim, Key, Ebook, Premium, Subject, Publisher from regluit.core import bookloader, models, search, goodreads, librarything from regluit.core import isbn from regluit.payment.parameters import PAYMENT_TYPE_AUTHORIZATION @@ -53,6 +53,17 @@ class BookLoaderTests(TestCase): # work self.assertTrue(edition.work) + # publisher names + old_pub_name = edition.publisher_name + edition.set_publisher('test publisher name') + self.assertEqual(edition.publisher, u'test publisher name') + pub = Publisher(name=edition.publisher_name) + pub.save() + self.assertEqual(edition.work.publishers().count(), 1) + old_pub_name.publisher = pub + old_pub_name.save() + edition.set_publisher(u'Ace Trade') + self.assertEqual(edition.publisher, u'test publisher name') # Ace Trade has been aliased # locale in language edition = bookloader.add_by_isbn('9787500676911') self.assertEqual(edition.work.language, 'zh') From 1ace0a54790d94dba32d7ac8bee37df83155a8d0 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 29 Mar 2013 11:50:07 -0400 Subject: [PATCH 08/14] "login to add" now adds, uses triple login page [#30497175] --- frontend/templates/registration/from_add.html | 2 ++ .../templates/registration/from_pledge.html | 2 +- frontend/views.py | 17 +++++++++++++++++ static/js/wishlist.js | 2 +- urls.py | 2 ++ 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 frontend/templates/registration/from_add.html diff --git a/frontend/templates/registration/from_add.html b/frontend/templates/registration/from_add.html new file mode 100644 index 00000000..bd2c2b0a --- /dev/null +++ b/frontend/templates/registration/from_add.html @@ -0,0 +1,2 @@ +{% extends "registration/from_pledge.html" %} +{% block login_pitch %}

Before we can add a book to your wishlist, you'll need to login or make an account.

{% endblock %} \ No newline at end of file diff --git a/frontend/templates/registration/from_pledge.html b/frontend/templates/registration/from_pledge.html index 51f51603..cf4bf41b 100644 --- a/frontend/templates/registration/from_pledge.html +++ b/frontend/templates/registration/from_pledge.html @@ -33,7 +33,7 @@ function put_un_in_cookie(){ {% block content %}
-

You'll need an account, since we won't charge your card unless the campaign succeeds!

+ {% block login_pitch %}

You'll need an account, since we won't charge your card unless the campaign succeeds!

{% endblock %} -{% endblock %} - - +{% endblock %} \ No newline at end of file diff --git a/settings/prod.py b/settings/prod.py index 1fc5be78..51dea2f5 100644 --- a/settings/prod.py +++ b/settings/prod.py @@ -146,7 +146,7 @@ CELERYBEAT_SCHEDULE['notify_ending_soon'] = NOTIFY_ENDING_SOON_JOB AMAZON_FPS_HOST = "fps.amazonaws.com" # local settings for maintenance mode -MAINTENANCE_MODE = False +MAINTENANCE_MODE = True # Amazon keys to permit S3 access DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' From 25fedc69ee3fa2d1c833fec033a5456385af98c2 Mon Sep 17 00:00:00 2001 From: Raymond Yee Date: Sat, 30 Mar 2013 10:25:32 -0700 Subject: [PATCH 13/14] get prod out of production mode --- settings/prod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/prod.py b/settings/prod.py index 06eb9541..5ab28bb6 100644 --- a/settings/prod.py +++ b/settings/prod.py @@ -146,7 +146,7 @@ CELERYBEAT_SCHEDULE['notify_ending_soon'] = NOTIFY_ENDING_SOON_JOB AMAZON_FPS_HOST = "fps.amazonaws.com" # local settings for maintenance mode -MAINTENANCE_MODE = True +MAINTENANCE_MODE = False # Amazon keys to permit S3 access DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' From 7dd1b994cd44bfc93746e5fcbf03de97767f6c52 Mon Sep 17 00:00:00 2001 From: Andromeda Yelton Date: Mon, 1 Apr 2013 10:28:19 -0400 Subject: [PATCH 14/14] fixing syntax error --- frontend/templates/notification/notice_settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/templates/notification/notice_settings.html b/frontend/templates/notification/notice_settings.html index aab3a888..0affa040 100644 --- a/frontend/templates/notification/notice_settings.html +++ b/frontend/templates/notification/notice_settings.html @@ -10,7 +10,7 @@ {% block extra_js %} -{% block.super %} +{{ block.super }}