Пример #1
0
 def render(self):
     points = list(AccountHelper.points(self.current_user))
     if points.count("tinyms.sidebar.archives.show"):
         self.archives_show = True
     if points.count("tinyms.sidebar.role_org.show"):
         self.role_org_show = True
     if points.count("tinyms.sidebar.sys_params.show"):
         self.sys_params_show = True
     custom_menus = ObjectPool.sidebar_menus
     first_levels = list()
     for menu in custom_menus:
         if menu[1].count("/") == 1:
             first_levels.append(menu)
     html_builder = list()
     self.sort_menus(first_levels)
     for first in first_levels:
         if first[4] and points.count(first[4]) == 0:
             continue
         p = (
             '<a href="'
             + first[2]
             + '"><i class="'
             + first[5]
             + ' icon-xlarge"></i><span>'
             + first[3]
             + "</span></a>"
         )
         subs = self.children(first[1])
         if len(subs) > 0:
             html_builder.append('<li class="dropdown-submenu">')
             html_builder.append(p)
             html_builder.append('<ul class="dropdown-menu">')
             self.sort_menus(subs)
             for sub in subs:
                 if sub[4] and points.count(sub[4]) == 0:
                     continue
                 html_builder.append('<li><a href="' + sub[2] + '">' + sub[3] + "</a></li>")
                 pass
             html_builder.append("</ul>")
             html_builder.append("</li>")
         else:
             html_builder.append("<li>" + p + "</li>")
     menu_html = "".join(html_builder)
     context = dict()
     context["menu"] = menu_html
     context["archives_show"] = self.archives_show
     context["role_org_show"] = self.role_org_show
     context["sys_params_show"] = self.sys_params_show
     context["dev"] = ObjectPool.mode_dev
     return self.render_string("workbench/sidebar.html", context=context)
Пример #2
0
 def get_current_account_points(self):
     """
     account security points: set('key1','key2',..)
     :return:
     """
     temp = set()
     if not self.get_current_user():
         return temp
     cache = CacheManager.get(500, 30 * 1000)
     points = cache.get(IRequest.__key_account_points__ % self.get_current_user())
     if points:
         print("Exists Cache Account Points")
         return points
     else:
         temp = temp.union(AccountHelper.points(self.get_current_user()))
         return temp