Browse Source

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

That way dashboards work eveb if only 'query' permission.
Romain Rigaux 11 năm trước cách đây
mục cha
commit
2e08c7d83e
2 tập tin đã thay đổi với 6 bổ sung1 xóa
  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