From 5ddaa4c44f54d552cd90631db59a70a58d86b75f Mon Sep 17 00:00:00 2001 From: kakwa Date: Thu, 11 Jun 2015 23:36:50 +0200 Subject: [PATCH] adding js to better handle parent/sub roles now js functions automatically enables parent roles of a selected roles, and disables sub roles unselected role --- ldapcherry/__init__.py | 21 ++++++++------------ resources/templates/roles.tmpl | 35 +++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index 4cbae86..3405066 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -457,8 +457,15 @@ class LdapCherry(object): """ add user page """ self._check_auth(must_admin=True) is_admin = self._check_admin() + + graph={} + for r in self.roles.graph: + s = list(self.roles.graph[r]['sub_roles']) + p = list(self.roles.graph[r]['parent_roles']) + graph[r] = { 'sub_roles': s, 'parent_roles': p} + graph_js = json.dumps(graph, separators=(',',':')) form = self.temp_form.render(attributes=self.attributes.attributes, values=None) - roles = self.temp_roles.render(roles=self.roles.flatten, graph=self.roles.graph) + roles = self.temp_roles.render(roles=self.roles.flatten, graph=self.roles.graph, graph_js=graph_js) return self.temp_adduser.render(form=form, roles=roles, is_admin=is_admin) @cherrypy.expose @@ -468,18 +475,6 @@ class LdapCherry(object): is_admin = self._check_admin() pass - @cherrypy.expose - def graph(self, **params): - """ remove user page """ - self._check_auth(must_admin=True) - is_admin = self._check_admin() - graph={} - for r in self.roles.graph: - s = list(self.roles.graph[r]['sub_roles']) - p = list(self.roles.graph[r]['parent_roles']) - graph[r] = { 'sub_roles': s, 'parent_roles': p} - return json.dumps(graph, separators=(',',':')) - @cherrypy.expose def modify(self, **params): """ modify user page """ diff --git a/resources/templates/roles.tmpl b/resources/templates/roles.tmpl index dba9b25..97233ab 100644 --- a/resources/templates/roles.tmpl +++ b/resources/templates/roles.tmpl @@ -1,3 +1,22 @@ + @@ -35,11 +54,21 @@ ${parents} % endfor
- - + +
-