migration and oth. minor fixes
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 14 Jun 2010 10:47:21 +0000 (12:47 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 14 Jun 2010 11:15:19 +0000 (13:15 +0200)
.gitignore
apps/catalogue/migrations/0006_epub_tag_counters_and_ltags_descendants.py
apps/catalogue/migrations/0007_remove_empty_html.py
apps/catalogue/models.py
apps/infopages/migrations/0001_initial.py

index 38a691b..ffdcd24 100644 (file)
@@ -4,10 +4,16 @@ dev.sqlite
 *~
 *.orig
 
+# Compress output
+/wolnelektury/static/css/all.min*.css
+/wolnelektury/static/js/all*.min.js
+/wolnelektury/static/js/jquery.min.js
+
 # Python garbage
 *.pyc
 .coverage
 pip-log.txt
+nosetests.xml
 
 # Mac OS X garbage
 .DS_Store
index dd2e6a2..7b2f2c5 100644 (file)
@@ -19,8 +19,8 @@ class Migration(SchemaMigration):
         """ Add _tag_counter and make sure all books carry their ancestors' l-tags """
 
         # Adding fields
-        db.add_column('catalogue_book', '_tag_counter', self.gf('catalogue.fields.JSONField')(default=''), keep_default=False)
-        db.add_column('catalogue_book', '_theme_counter', self.gf('catalogue.fields.JSONField')(default=''), keep_default=False)
+        db.add_column('catalogue_book', '_tag_counter', self.gf('catalogue.fields.JSONField')(null=True))
+        db.add_column('catalogue_book', '_theme_counter', self.gf('catalogue.fields.JSONField')(null=True))
         db.add_column('catalogue_book', 'epub_file', self.gf('django.db.models.fields.files.FileField')(default='', max_length=100, blank=True), keep_default=False)
 
         def ltag_descendants(book, ltags=None):
@@ -104,8 +104,8 @@ class Migration(SchemaMigration):
             '_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'}),
index ec882b9..ca87ccb 100644 (file)
@@ -9,7 +9,7 @@ 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)):
@@ -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'}),
index 55a2b64..37e6c2e 100644 (file)
@@ -131,8 +131,8 @@ class Book(models.Model):
     tagged = managers.ModelTaggedItemManager(Tag)
     tags = managers.TagDescriptor(Tag)
     
-    _tag_counter = JSONField(editable=False, default='')
-    _theme_counter = JSONField(editable=False, default='')
+    _tag_counter = JSONField(null=True, editable=False)
+    _theme_counter = JSONField(null=True, editable=False)
 
     class AlreadyExists(Exception):
         pass
@@ -376,10 +376,9 @@ class Book(models.Model):
     
     @property
     def tag_counter(self):
-        if self._tag_counter == '':
+        if self._tag_counter is None:
             return self.refresh_tag_counter()
         return dict((int(k), v) for k, v in self.get__tag_counter_value().iteritems())
-        #return self.get__tag_counter_value()
 
     def refresh_theme_counter(self):
         tags = {}
@@ -392,10 +391,9 @@ class Book(models.Model):
     
     @property
     def theme_counter(self):
-        if self._theme_counter == '':
+        if self._theme_counter is None:
             return self.refresh_theme_counter()
         return dict((int(k), v) for k, v in self.get__theme_counter_value().iteritems())
-        return self.get__theme_counter_value()
     
 
 
index 94ca2b3..a1289a2 100644 (file)
@@ -50,8 +50,9 @@ class Migration(SchemaMigration):
             ('page_title_ru', self.gf('django.db.models.fields.CharField')(max_length=120, null=True, blank=True)),
         ))
 
-        from django.core.management import call_command
-        call_command("loaddata", "wl_data")
+        if not db.dry_run:
+            from django.core.management import call_command
+            call_command("loaddata", "wl_data")
 
         db.send_create_signal('infopages', ['InfoPage'])