浏览代码

HUE-3784 [editor] Query list page does not list shared queries, only owned ones

Jenny Kim 9 年之前
父节点
当前提交
c873186243
共有 1 个文件被更改,包括 9 次插入2 次删除
  1. 9 2
      desktop/libs/notebook/src/notebook/views.py

+ 9 - 2
desktop/libs/notebook/src/notebook/views.py

@@ -21,6 +21,7 @@ import logging
 from django.db.models import Q
 from django.utils.translation import ugettext as _
 
+from desktop.conf import USE_NEW_EDITOR
 from desktop.lib.django_util import render, JsonResponse
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.json_utils import JSONEncoderForHTML
@@ -43,9 +44,15 @@ def notebooks(request):
   editor_type = request.GET.get('type', 'notebook')
 
   if editor_type != 'notebook':
-    notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query')) if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type]
+    if USE_NEW_EDITOR.get():
+      notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['query-%s' % editor_type])]
+    else:
+      notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query')) if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type]
   else:
-    notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook')) if not d.content_object.is_history]
+    if USE_NEW_EDITOR.get():
+      notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['notebook'])]
+    else:
+      notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook')) if not d.content_object.is_history]
 
   return render('notebooks.mako', request, {
       'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML),