Эх сурвалжийг харах

HUE-777 [core] Move logic to the view

Romain Rigaux 13 жил өмнө
parent
commit
7ba3a71390

+ 2 - 0
desktop/core/src/desktop/appmanager.py

@@ -191,6 +191,8 @@ class DesktopModuleInfo(object):
   def __str__(self):
     return "DesktopModule(%s: %s)" % (self.nice_name, self.module.__name__)
 
+def get_apps(user):
+  return filter(lambda app: user.has_hue_permission(action="access", app=app.display_name), DESKTOP_APPS)
 
 def load_libs():
   global DESKTOP_MODULES

+ 1 - 1
desktop/core/src/desktop/templates/common_header.mako

@@ -120,7 +120,7 @@ from django.utils.translation import ugettext as _
         <div class="nav-collapse">
           <ul class="nav">
             %for app in apps:
-              %if app.icon_path and user.has_hue_permission(action="access", app=app.display_name):
+              %if app.icon_path:
               <li id="${app.display_name}Icon" ${is_selected(section, app.display_name)}>
                 <a class="nav-tooltip" title="${app.nice_name}" href="/${app.display_name}"><img src="${app.icon_path}" /></a>
               </li>

+ 1 - 2
desktop/core/src/desktop/views.py

@@ -267,8 +267,7 @@ def commonheader(title, section, user, padding="60px"):
   """
   Returns the rendered common header
   """
-  apps_list = sorted(appmanager.DESKTOP_APPS[:], key=lambda app: app.menu_index)
-  #apps_list = sorted(appmanager.get_apps(user), key=lambda app: app.menu_index)
+  apps_list = sorted(appmanager.get_apps(user), key=lambda app: app.menu_index)
 
   return django_mako.render_to_string("common_header.mako", dict(
     apps=apps_list,