فهرست منبع

[core] Fix doc model syncing missing some empty objects

Romain Rigaux 11 سال پیش
والد
کامیت
d88cb9f
2فایلهای تغییر یافته به همراه4 افزوده شده و 3 حذف شده
  1. 3 2
      desktop/core/src/desktop/management/commands/sync_documents.py
  2. 1 1
      desktop/core/src/desktop/models.py

+ 3 - 2
desktop/core/src/desktop/management/commands/sync_documents.py

@@ -25,6 +25,7 @@ from desktop.models import Document
 class Command(NoArgsCommand):
 
   def handle_noargs(self, **options):
-    logging.info('Creating document objects...')
+    logging.info('Running syncing document command.')
+    self.stdout.write('Syncing document objects...\n')
     Document.objects.sync()
-    logging.info('Documents created.')
+    self.stdout.write('Documents synced.\n')

+ 1 - 1
desktop/core/src/desktop/models.py

@@ -334,7 +334,7 @@ class DocumentManager(models.Manager):
     # Delete documents with no object
     try:
       for doc in Document.objects.all():
-        if doc.content_type is None:
+        if doc.content_type is None or doc.content_object is None:
           doc.delete()
     except Exception, e:
       LOG.warn(force_unicode(e))