Esempio n. 1
0
 def has_secret(self):
     """
     Check current user has *secret* permission on given app
     :return:
     """
     perm_name = "%s:secret" % (self.get_app_id().replace(".", ":"))
     return perm_name in Permission.get_effective_permissions(get_user())
Esempio n. 2
0
    def get_launch_info(self, request):
        """
        Return desktop launch information
        """
        from noc.aaa.models.permission import Permission

        user = request.user
        # Amount of characters to strip
        lps = len(self.get_app_id()) + 1
        # Get effective user permissions
        user_perms = Permission.get_effective_permissions(user)
        # Leave only application permissions
        # and strip <module>:<app>:
        app_perms = [p[lps:] for p in user_perms & self.get_permissions()]
        return {
            "class": self.js_app_class,
            "title": unicode(self.title),
            "params": {
                "url": self.menu_url,
                "permissions": app_perms,
                "app_id": self.app_id,
                "link": self.link,
            },
        }