示例#1
0
 def admin(self):
     # Check if the user is an admin
     if cherrypy.session.get("usertype", "user") == "admin":
         tmpl = lookup.get_template("admin.html.mako")
         if settings['web_use_auth'] == "true":
             return tmpl.render(
                                 username = cherrypy.session['username'],
                                 userimageurl = cherrypy.session['userimageurl'],
                                 usertype = cherrypy.session['usertype'],
                                 settings = settings,
                                 users = API.get_users(),
                                 hooks = API.get_hooks()
                               )
         else:
             return tmpl.render(
                                 username = cherrypy.session.get("username", "dev"),
                                 userimageurl = cherrypy.session.get("userimageurl", "dev"),
                                 usertype = cherrypy.session.get("usertype", "admin"),
                                 settings = settings,
                                 users = API.get_users(),
                                 hooks = API.get_hooks()
                               )
     else:
         return json.dumps({"error": "User not authorized for this request"})
示例#2
0
 def get_hooks(self, id=None, action=None, target=None, state=None, api_token=None):
     return API.get_hooks(id, action, target, state, api_token)