Răsfoiți Sursa

HUE-1025 [fb] Explicit permission error message

Added explicit message in case of error when a path is requested via ajax
Enrico Berti 13 ani în urmă
părinte
comite
fa9ebe84cf

+ 5 - 0
apps/filebrowser/src/filebrowser/templates/listdir_components.mako

@@ -829,6 +829,11 @@ from django.utils.translation import ugettext as _
       self.retrieveData = function () {
         self.isLoading(true);
         $.getJSON(self.targetPath() + "?pagesize=" + self.recordsPerPage() + "&pagenum=" + self.targetPageNum() + "&filter=" + self.searchQuery() + "&sortby=" + self.sortBy() + "&descending=" + self.sortDescending() + "&format=json", function (data) {
+          if (data.error){
+            $.jHueNotify.error(data.error);
+            self.isLoading(false);
+            return false;
+          }
           if (data.type != null && data.type == "file") {
             location.href = data.url;
             return false;

+ 7 - 1
apps/filebrowser/src/filebrowser/views.py

@@ -144,7 +144,13 @@ def view(request, path):
         msg = _("Cannot access: %(path)s.") % {'path': escape(path)}
         if request.user.is_superuser and not request.user == request.fs.superuser:
             msg += _(' Note: you are a Hue admin but not a HDFS superuser (which is "%(superuser)s").') % {'superuser': request.fs.superuser}
-        raise PopupException(msg , detail=e)
+        if request.is_ajax():
+          exception = {
+            'error': msg
+          }
+          return render_json(exception)
+        else:
+          raise PopupException(msg , detail=e)
 
 
 def home_relative_view(request, path):