浏览代码

[search] Delete Document2 search dashboards

Romain Rigaux 10 年之前
父节点
当前提交
d04b4bd474
共有 2 个文件被更改,包括 5 次插入4 次删除
  1. 4 2
      apps/search/src/search/search_controller.py
  2. 1 2
      desktop/core/src/desktop/models.py

+ 4 - 2
apps/search/src/search/search_controller.py

@@ -68,8 +68,10 @@ class SearchController(object):
   def delete_collections(self, collection_ids):
     result = {'status': -1, 'message': ''}
     try:
-      # todo
-      self.get_owner_search_collections().filter(id__in=collection_ids).delete()
+      for doc2 in self.get_owner_search_collections().filter(id__in=collection_ids):
+        doc = doc2.doc.get()
+        doc.delete()
+        doc2.delete()
       result['status'] = 0
     except Exception, e:
       LOG.warn('Error deleting collection: %s' % e)

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

@@ -341,9 +341,8 @@ class DocumentManager(models.Manager):
               owner = dashboard.owner
             dashboard_doc = Document2.objects.create(name=dashboard.label, uuid=_uuid, type='search-dashboard', owner=owner, description=dashboard.label, data=dashboard.properties)
             Document.objects.link(dashboard_doc, owner=owner, name=dashboard.label, description=dashboard.label, extra='search-dashboard')
-            dashboard.save()    
+            dashboard.save()
     except Exception, e:
-      print e
       LOG.warn(force_unicode(e))
 
     try: