소스 검색

[search] Send back current collection when no Sentry permission to list collections

That way dashboards work eveb if only 'query' permission.
Romain Rigaux 11 년 전
부모
커밋
2e08c7d
2개의 변경된 파일6개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      apps/search/src/search/views.py
  2. 1 0
      apps/search/static/js/search.ko.js

+ 5 - 1
apps/search/src/search/views.py

@@ -534,7 +534,11 @@ def get_collections(request):
     result['status'] = 0
 
   except Exception, e:
-    result['message'] = unicode(str(e), "utf8")
+    if 'does not have privileges' in str(e):
+      result['status'] = 0
+      result['collection'] = [json.loads(request.POST.get('collection'))['name']]
+    else:
+      result['message'] = unicode(str(e), "utf8")
 
   return HttpResponse(json.dumps(result), mimetype="application/json")
 

+ 1 - 0
apps/search/static/js/search.ko.js

@@ -848,6 +848,7 @@ var NewTemplate = function (vm, initial) {
 
   self.syncCollections = function () {
     $.post("/search/get_collections", {
+        collection: ko.mapping.toJSON(vm.collection),
       }, function (data) {
         if (data.status == 0) {
           // Sync new and old names