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

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

@@ -534,7 +534,11 @@ def get_collections(request):
     result['status'] = 0
     result['status'] = 0
 
 
   except Exception, e:
   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")
   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 () {
   self.syncCollections = function () {
     $.post("/search/get_collections", {
     $.post("/search/get_collections", {
+        collection: ko.mapping.toJSON(vm.collection),
       }, function (data) {
       }, function (data) {
         if (data.status == 0) {
         if (data.status == 0) {
           // Sync new and old names
           // Sync new and old names