From 6431b691f2335a3c614bfe153267bc5c58add51c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 31 Aug 2011 14:52:16 +0200 Subject: [PATCH] merge migrations, fix for south, fix for media in api --- apps/api/handlers.py | 2 +- apps/catalogue/fields.py | 22 ++++++++----------- ..._add_field_tag_created_at__add_field_t.py} | 3 ++- ... => 0012_auto__add_field_book_sort_key.py} | 3 ++- .../{0009_sortify.py => 0013_sortify.py} | 3 ++- 5 files changed, 16 insertions(+), 17 deletions(-) rename apps/catalogue/migrations/{0007_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py => 0011_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py} (98%) rename apps/catalogue/migrations/{0008_auto__add_field_book_sort_key.py => 0012_auto__add_field_book_sort_key.py} (97%) rename apps/catalogue/migrations/{0009_sortify.py => 0013_sortify.py} (97%) diff --git a/apps/api/handlers.py b/apps/api/handlers.py index 832f34f0b..9bb65d00e 100644 --- a/apps/api/handlers.py +++ b/apps/api/handlers.py @@ -67,7 +67,7 @@ class CatalogueHandler(BaseHandler): elif field in ('mp3', 'ogg', 'daisy'): media = [] for m in book.media.filter(type=field): - files.append({ + media.append({ 'url': m.file.get_absolute_url(), 'size': m.file.size, }) diff --git a/apps/catalogue/fields.py b/apps/catalogue/fields.py index e11d611e5..510c06dac 100644 --- a/apps/catalogue/fields.py +++ b/apps/catalogue/fields.py @@ -114,19 +114,6 @@ class JQueryAutoCompleteField(forms.CharField): super(JQueryAutoCompleteField, self).__init__(*args, **kwargs) -try: - # check for south - from south.modelsinspector import add_introspection_rules - - add_introspection_rules([ - ( - [JSONField], # Class(es) these apply to - [], # Positional arguments (not used) - {}, # Keyword argument - ), ], ["^catalogue\.fields\.JSONField"]) -except ImportError: - pass - class OverwritingFieldFile(FieldFile): """ @@ -143,3 +130,12 @@ class OverwritingFieldFile(FieldFile): class OverwritingFileField(models.FileField): attr_class = OverwritingFieldFile + +try: + # check for south + from south.modelsinspector import add_introspection_rules + + add_introspection_rules([], ["^catalogue\.fields\.JSONField"]) + add_introspection_rules([], ["^catalogue\.fields\.OverwritingFileField"]) +except ImportError: + pass diff --git a/apps/catalogue/migrations/0007_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py b/apps/catalogue/migrations/0011_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py similarity index 98% rename from apps/catalogue/migrations/0007_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py rename to apps/catalogue/migrations/0011_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py index b339c0586..2f573ba1b 100644 --- a/apps/catalogue/migrations/0007_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py +++ b/apps/catalogue/migrations/0011_auto__add_field_book_changed_at__add_field_tag_created_at__add_field_t.py @@ -87,7 +87,6 @@ class Migration(SchemaMigration): 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}), 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'medias': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.BookMedia']", 'symmetrical': 'False', 'blank': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'children'", 'blank': 'True', 'null': 'True', 'to': "orm['catalogue.Book']"}), 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'pdf_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), @@ -99,10 +98,12 @@ class Migration(SchemaMigration): }, 'catalogue.bookmedia': { 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'}, + 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}), 'extra_info': ('catalogue.fields.JSONField', [], {'default': "'{}'"}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), + 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) }, diff --git a/apps/catalogue/migrations/0008_auto__add_field_book_sort_key.py b/apps/catalogue/migrations/0012_auto__add_field_book_sort_key.py similarity index 97% rename from apps/catalogue/migrations/0008_auto__add_field_book_sort_key.py rename to apps/catalogue/migrations/0012_auto__add_field_book_sort_key.py index 22ddb52ca..466e8cc22 100644 --- a/apps/catalogue/migrations/0008_auto__add_field_book_sort_key.py +++ b/apps/catalogue/migrations/0012_auto__add_field_book_sort_key.py @@ -69,7 +69,6 @@ class Migration(SchemaMigration): 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}), 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'medias': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.BookMedia']", 'symmetrical': 'False', 'blank': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}), 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'pdf_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), @@ -82,10 +81,12 @@ class Migration(SchemaMigration): }, 'catalogue.bookmedia': { 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'}, + 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}), 'extra_info': ('catalogue.fields.JSONField', [], {'default': "'{}'"}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), + 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) }, diff --git a/apps/catalogue/migrations/0009_sortify.py b/apps/catalogue/migrations/0013_sortify.py similarity index 97% rename from apps/catalogue/migrations/0009_sortify.py rename to apps/catalogue/migrations/0013_sortify.py index 157fac6e2..bc1218952 100644 --- a/apps/catalogue/migrations/0009_sortify.py +++ b/apps/catalogue/migrations/0013_sortify.py @@ -77,7 +77,6 @@ class Migration(DataMigration): 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}), 'html_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'medias': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['catalogue.BookMedia']", 'symmetrical': 'False', 'blank': 'True'}), 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}), 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'pdf_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), @@ -90,10 +89,12 @@ class Migration(DataMigration): }, 'catalogue.bookmedia': { 'Meta': {'ordering': "('type', 'name')", 'object_name': 'BookMedia'}, + 'book': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'media'", 'to': "orm['catalogue.Book']"}), 'extra_info': ('catalogue.fields.JSONField', [], {'default': "'{}'"}), 'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), + 'source_sha1': ('django.db.models.fields.CharField', [], {'max_length': '40', 'null': 'True', 'blank': 'True'}), 'type': ('django.db.models.fields.CharField', [], {'max_length': "'100'"}), 'uploaded_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}) }, -- 2.20.1