Explorar el Código

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

That way dashboards work eveb if only 'query' permission.
Romain Rigaux hace 11 años
padre
commit
2e08c7d83e
Se han modificado 2 ficheros con 6 adiciones y 1 borrados
  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