Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 6160)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 6161)
@@ -48,6 +48,51 @@
     user = form['user']
     role_manager = IPrincipalRoleManager(view.context)
+    role_manager.assignRoleToPrincipal(localrole, user)
+    view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab)
+    return
+
+def get_users_with_local_roles(view):
+    role_manager = IPrincipalRoleManager(view.context)
     role_map = IPrincipalRoleMap(view.context)
-    role_manager.assignRoleToPrincipal(localrole, user)
+    for item in role_map.getPrincipalsAndRoles():
+        local_role = item[0]
+        user_name = item[1]
+        setting = item[2]
+        user = grok.getSite()['users'].get(user_name,None)
+        roles_dict = view.context.local_roles
+        local_role_title = roles_dict[local_role]
+        if user:
+            yield(dict(user_name=user_name, user_title=user.description,
+                local_role=local_role, local_role_title=local_role_title,
+                setting=setting))
+        else:
+            yield(dict(user_name=user_name, user_title=user_name,
+                local_role=local_role, local_role_title=local_role_title,
+                setting=setting))
+
+def del_local_roles(view, tab, **data):
+    form = view.request.form
+    if form.has_key('role_id'):
+        child_id = form['role_id']
+    else:
+        view.flash('No local role selected!')
+        view.redirect(view.url(view.context, '@@manage')+'#tab-%s' % tab)
+        return
+    if not isinstance(child_id, list):
+        child_id = [child_id]
+    #import pdb; pdb.set_trace()
+    deleted = []
+    role_manager = IPrincipalRoleManager(view.context)
+    for id in child_id:
+        localrole = id.split('|')[1]
+        user_name = id.split('|')[0]
+        try:
+            role_manager.unsetRoleForPrincipal(localrole, user_name)
+            deleted.append(id)
+        except:
+            view.flash('Could not remove %s: %s: %s' % (
+                    id, sys.exc_info()[0], sys.exc_info()[1]))
+    if len(deleted):
+        view.flash('Successfully removed: %s' % ', '.join(deleted))
     view.redirect(view.url(view.context, u'@@manage')+'#tab-%s' % tab)
     return
@@ -859,5 +904,10 @@
     def delFaculties(self, **data):
         form = self.request.form
-        child_id = form['val_id']
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No faculty selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-1')
+            return
         if not isinstance(child_id, list):
             child_id = [child_id]
@@ -947,5 +997,6 @@
     taboneactions = ['Save','Cancel']
     tabtwoactions = ['Add department', 'Remove selected','Cancel']
-    tabthreeactions = ['Add local role', 'Remove local roles selected']
+    tabthreeactions1 = ['Remove selected local roles']
+    tabthreeactions2 = ['Add local role']
 
     form_fields = grok.AutoFields(IFaculty)
@@ -961,5 +1012,5 @@
     def update(self):
         tabs.need()
-        #warning.need()
+        datatable.need()
         return super(FacultyManageFormPage, self).update()
 
@@ -974,4 +1025,7 @@
             url = self.url(val)
             yield(dict(url=url, name=key, val=val))
+
+    def getUsersWithLocalRoles(self):
+        return get_users_with_local_roles(self)
 
     # ToDo: Show warning message before deletion
@@ -982,6 +1036,6 @@
             child_id = form['val_id']
         else:
-            self.flash('No subunit selected!')
-            self.redirect(self.url(self.context, '@@manage')+'#tab-%s' % tab)
+            self.flash('No department selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-2')
             return
         if not isinstance(child_id, list):
@@ -1019,4 +1073,8 @@
         return add_local_role(self, '3', **data)
 
+    @grok.action('Remove selected local roles')
+    def delLocalRoles(self, **data):
+        return del_local_roles(self,3,**data)
+
 class DepartmentAddFormPage(WAeUPAddFormPage):
     """Add a department to a faculty.
@@ -1100,5 +1158,6 @@
     tabtwoactions = ['Add course', 'Remove selected courses','Cancel']
     tabthreeactions = ['Add certificate', 'Remove selected certificates', 'Cancel']
-    tabfouractions = ['Add local role', 'Remove local roles selected']
+    tabfouractions1 = ['Remove selected local roles']
+    tabfouractions2 = ['Add local role']
 
     form_fields = grok.AutoFields(IDepartment)
@@ -1142,4 +1201,7 @@
             url = self.url(val)
             yield(dict(url=url, name=key, val=val))
+            
+    def getUsersWithLocalRoles(self):
+        return get_users_with_local_roles(self)
 
     @grok.action('Save')
@@ -1152,5 +1214,10 @@
     def delCourses(self, **data):
         form = self.request.form
-        child_id = form['val_id']
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No course selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-2')
+            return
         if not isinstance(child_id, list):
             child_id = [child_id]
@@ -1171,5 +1238,10 @@
     def delCertificates(self, **data):
         form = self.request.form
-        child_id = form['val_id']
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No certificate selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-3')
+            return
         if not isinstance(child_id, list):
             child_id = [child_id]
@@ -1206,4 +1278,8 @@
         return add_local_role(self, 4, **data)
 
+    @grok.action('Remove selected local roles')
+    def delLocalRoles(self, **data):
+        return del_local_roles(self,4,**data)
+
 class CourseAddFormPage(WAeUPAddFormPage):
     """Add-form to add course to a department.
@@ -1396,5 +1472,10 @@
     def delCertificateCourses(self, **data):
         form = self.request.form
-        child_id = form['val_id']
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No course referrer selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-2')
+            return
         if not isinstance(child_id, list):
             child_id = [child_id]
Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css	(revision 6160)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/static/waeup-base.css	(revision 6161)
@@ -66,4 +66,8 @@
 .ui-tabs .ui-tabs-nav li a:hover {
   text-decoration: underline;
+}
+
+.dataTables_wrapper {
+  min-height: 100px;
 }
 
Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentmanagepage.pt
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentmanagepage.pt	(revision 6160)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/departmentmanagepage.pt	(revision 6161)
@@ -31,44 +31,42 @@
    
 <div id="tab-1">        
-      <table class="zebra">
-      <tbody>
-      <tal:block repeat="widget view/widgets">
-        <tr>
-          <td class="label" tal:define="hint widget/hint">
-    	<label tal:condition="python:hint"
-    	       tal:attributes="for widget/name">
-    	  <span class="required" tal:condition="widget/required"
-    		>*</span><span i18n:translate=""
-    		tal:content="widget/label">label</span>
-    	</label>
-    	<label tal:condition="python:not hint"
-    	       tal:attributes="for widget/name">
-    	  <span class="required" tal:condition="widget/required"
-    		>*</span><span i18n:translate=""
-    		tal:content="widget/label">label</span>
-    	</label>:
-          </td>
-          <td class="field">
-    	<div class="widget" tal:content="structure widget">
-    	  <input type="text" />
-    	</div>
-    	<div class="error" tal:condition="widget/error">
-    	  <span tal:replace="structure widget/error">error</span>
-    	</div>
-          </td>
-        </tr>
-      </tal:block>
-      </tbody>
-      </table>
-
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.taboneactions"
-                     tal:replace="structure action/render"/>
-            </span>
-        </span>
-    </div>   
+    <table class="zebra">
+        <tbody>
+        <tal:block repeat="widget view/widgets">
+            <tr>
+              <td class="label" tal:define="hint widget/hint">
+            <label tal:condition="python:hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+            	>*</span><span i18n:translate=""
+            	tal:content="widget/label">label</span>
+            </label>
+            <label tal:condition="python:not hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+            	>*</span><span i18n:translate=""
+            	tal:content="widget/label">label</span>
+            </label>:
+              </td>
+              <td class="field">
+            <div class="widget" tal:content="structure widget">
+              <input type="text" />
+            </div>
+            <div class="error" tal:condition="widget/error">
+              <span tal:replace="structure widget/error">error</span>
+            </div>
+              </td>
+            </tr>
+        </tal:block>
+        </tbody>
+    </table>
+
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.taboneactions"
+                 tal:replace="structure action/render"/>
+        </span>
+    </div>
 
 </div>    
@@ -100,13 +98,11 @@
     </table>
     <br /><br />
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.tabtwoactions"
-                     tal:replace="structure action/render"/>
-            </span>
-        </span>
-    </div>         
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.tabtwoactions"
+                 tal:replace="structure action/render"/>
+        </span>
+    </div>
 </div>
 
@@ -137,22 +133,46 @@
     </table>
     <br /><br />
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.tabthreeactions"
-                     tal:replace="structure action/render"/>
-            </span>
-        </span>
-    </div>         
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.tabthreeactions"
+                 tal:replace="structure action/render"/>
+        </span>
+    </div>
 </div> 
 
 <div id="tab-4">
-    <h3>Manage local roles</h3>
+    <br />
+    <table class="display dataTableManage">
+      <thead>
+        <tr>
+          <th>&nbsp;</th><th>User</th><th>Local Role</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr tal:repeat="entry view/getUsersWithLocalRoles"
+    	class="gradeB">
+    	  <td>
+            <input type="checkbox" name="role_id"
+                tal:attributes="value python: entry['user_name']+'|'+entry['local_role']" />
+          </td>
+          <td tal:content="entry/user_title">User
+          </td>
+          <td tal:content="entry/local_role_title">
+    	       Local Role
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.tabfouractions1"
+                 tal:replace="structure action/render"/>
+        </span>
+    </div>
+    <br /><br />
     <table class="zebra">
     <tr>
-        <td>
-        <label>User:</label>
-        </td>
         <td>
             <select  id="user" name="user"  tal:repeat="user view/getUsers">
@@ -161,9 +181,4 @@
               </option>
             </select>
-        </td>
-    </tr>
-    <tr>
-        <td>
-        <label>Local Role:</label>
         </td>
         <td>
@@ -174,18 +189,17 @@
             </select>
         </td>
+        <td>
+            <div class="actionButtons" tal:condition="view/availableActions">
+                <span tal:repeat="action view/actions"
+                      tal:omit-tag="">
+                  <input tal:condition="python:action.label in view.tabfouractions2"
+                         tal:replace="structure action/render"/>
+                </span>
+            </div>
+        </td>
+        
     </tr>
     </table>
-
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.tabfouractions"
-                     tal:replace="structure action/render"/>
-            </span>
-        </span>
-    </div>
-</div>
-    
+</div>
 </div>
 </form>  
Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt	(revision 6160)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt	(revision 6161)
@@ -30,44 +30,42 @@
    
 <div id="tab-1">        
-      <table class="zebra">
-      <tbody>
-      <tal:block repeat="widget view/widgets">
-        <tr>
-          <td class="label" tal:define="hint widget/hint">
-    	<label tal:condition="python:hint"
-    	       tal:attributes="for widget/name">
-    	  <span class="required" tal:condition="widget/required"
-    		>*</span><span i18n:translate=""
-    		tal:content="widget/label">label</span>
-    	</label>
-    	<label tal:condition="python:not hint"
-    	       tal:attributes="for widget/name">
-    	  <span class="required" tal:condition="widget/required"
-    		>*</span><span i18n:translate=""
-    		tal:content="widget/label">label</span>
-    	</label>:
-          </td>
-          <td class="field">
-    	<div class="widget" tal:content="structure widget">
-    	  <input type="text" />
-    	</div>
-    	<div class="error" tal:condition="widget/error">
-    	  <span tal:replace="structure widget/error">error</span>
-    	</div>
-          </td>
-        </tr>
-      </tal:block>
-      </tbody>
-      </table>
+    <table class="zebra">
+        <tbody>
+        <tal:block repeat="widget view/widgets">
+            <tr>
+              <td class="label" tal:define="hint widget/hint">
+            <label tal:condition="python:hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+            	>*</span><span i18n:translate=""
+            	tal:content="widget/label">label</span>
+            </label>
+            <label tal:condition="python:not hint"
+                   tal:attributes="for widget/name">
+              <span class="required" tal:condition="widget/required"
+            	>*</span><span i18n:translate=""
+            	tal:content="widget/label">label</span>
+            </label>:
+              </td>
+              <td class="field">
+            <div class="widget" tal:content="structure widget">
+              <input type="text" />
+            </div>
+            <div class="error" tal:condition="widget/error">
+              <span tal:replace="structure widget/error">error</span>
+            </div>
+              </td>
+            </tr>
+        </tal:block>
+        </tbody>
+    </table>
 
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.taboneactions"
-                     tal:replace="structure action/render"/>
-            </span>
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.taboneactions"
+                 tal:replace="structure action/render"/>
         </span>
-    </div>   
+    </div>
 
 </div>    
@@ -75,5 +73,5 @@
 <div id="tab-2">
   <h3 tal:content="view/subunits">Departments</h3>
-  <table class="zebra">
+    <table class="zebra">
     <thead>
       <tr>
@@ -101,24 +99,48 @@
       </tr>
     </tbody>
-  </table>
+    </table>
   
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.tabtwoactions"
-                     tal:replace="structure action/render"/>
-            </span>
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.tabtwoactions"
+                 tal:replace="structure action/render"/>
         </span>
-    </div>      
+    </div>
 </div>
 
 <div id="tab-3">
-    <h3>Manage local roles</h3>
+    <br />
+    <table class="display dataTableManage">
+      <thead>
+        <tr>
+          <th>&nbsp;</th><th>User</th><th>Local Role</th>
+        </tr>
+      </thead>
+      <tbody>
+        <tr tal:repeat="entry view/getUsersWithLocalRoles"
+    	class="gradeB">
+    	  <td>
+            <input type="checkbox" name="role_id"
+                tal:attributes="value python: entry['user_name']+'|'+entry['local_role']" />
+          </td>
+          <td tal:content="entry/user_title">User
+          </td>
+          <td tal:content="entry/local_role_title">
+    	       Local Role
+          </td>
+        </tr>
+      </tbody>
+    </table>
+    <div class="actionButtons" tal:condition="view/availableActions">
+        <span tal:repeat="action view/actions"
+              tal:omit-tag="">
+          <input tal:condition="python:action.label in view.tabthreeactions1"
+                 tal:replace="structure action/render"/>
+        </span>
+    </div>
+    <br /><br />
     <table class="zebra">
     <tr>
-        <td>
-        <label>User:</label>
-        </td>
         <td>
             <select  id="user" name="user"  tal:repeat="user view/getUsers">
@@ -127,9 +149,4 @@
               </option>
             </select>
-        </td>
-    </tr>
-    <tr>
-        <td>
-        <label>Local Role:</label>
         </td>
         <td>
@@ -140,16 +157,15 @@
             </select>
         </td>
+        <td>
+            <div class="actionButtons" tal:condition="view/availableActions">
+                <span tal:repeat="action view/actions"
+                      tal:omit-tag="">
+                  <input tal:condition="python:action.label in view.tabthreeactions2"
+                         tal:replace="structure action/render"/>
+                </span>
+            </div>
+        </td>
     </tr>
     </table>
-
-    <div id="actionsView">
-        <span class="actionButtons" tal:condition="view/availableActions">
-            <span tal:repeat="action view/actions"
-                  tal:omit-tag="">
-              <input tal:condition="python:action.label in view.tabthreeactions"
-                     tal:replace="structure action/render"/>
-            </span>
-        </span>
-    </div>
 </div>
 
