X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f33c3f5d2b0714abeb7b4e3164e2b0fe07f3cfb3..9c5d9a4e77a10b4e60d89d3890e49002bd7f3993:/apps/catalogue/migrations/0007_remove_empty_html.py diff --git a/apps/catalogue/migrations/0007_remove_empty_html.py b/apps/catalogue/migrations/0007_remove_empty_html.py index ec882b9c4..5b6f45393 100644 --- a/apps/catalogue/migrations/0007_remove_empty_html.py +++ b/apps/catalogue/migrations/0007_remove_empty_html.py @@ -5,12 +5,12 @@ from south.v2 import DataMigration from django.db import models class Migration(DataMigration): - + def forwards(self, orm): """ Look for HTML files without any real content and delete them """ from lxml import etree - from librarian import html_has_content - + from librarian.html import html_has_content + for book in orm.Book.objects.exclude(html_file=''): if not html_has_content(etree.parse(book.html_file)): book.html_file.delete() @@ -18,11 +18,11 @@ class Migration(DataMigration): for key in filter(lambda x: x.startswith('_short_html'), book.__dict__): book.__setattr__(key, '') book.save() - + def backwards(self, orm): """ Do nothing. We don't want empty HTML files anyway. """ pass - + models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -64,8 +64,8 @@ class Migration(DataMigration): '_short_html_pl': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), '_short_html_ru': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), '_short_html_uk': ('django.db.models.fields.TextField', [], {'null': True, 'blank': True}), - '_tag_counter': ('catalogue.fields.JSONField', [], {'default': "''"}), - '_theme_counter': ('catalogue.fields.JSONField', [], {'default': "''"}), + '_tag_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}), + '_theme_counter': ('catalogue.fields.JSONField', [], {'null': 'True'}), 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 'epub_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'blank': 'True'}), @@ -142,5 +142,5 @@ class Migration(DataMigration): 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) } } - + complete_apps = ['catalogue']