Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 6150)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 6151)
@@ -113,4 +113,76 @@
 #
 
+class ContainerManageFormPage(WAeUPEditFormPage):
+    """Manage the basic properties of a container instance with local roles
+    and contents This is the base class for faculty and department containers
+    """
+    grok.name('manage')
+    grok.require('waeup.manageUniversity')
+    taboneactions = ['Save','Cancel']
+    tabtwoactions = ['Add subunit', 'Remove selected','Cancel']
+    tabthreeactions = ['Add local role', 'Remove local roles selected']
+
+    # ToDo: Show warning message before deletion
+    @grok.action('Remove selected')
+    def delSubobjects(self, **data):
+        form = self.request.form
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No subunit selected!')
+            self.redirect(self.url(self.context, '@@manage')+'#tab-2')
+            return
+        if not isinstance(child_id, list):
+            child_id = [child_id]
+        deleted = []
+        for id in child_id:
+            try:
+                del self.context[id]
+                deleted.append(id)
+            except:
+                self.flash('Could not delete %s: %s: %s' % (
+                        id, sys.exc_info()[0], sys.exc_info()[1]))
+        if len(deleted):
+            self.flash('Successfully removed: %s' % ', '.join(deleted))
+        self.redirect(self.url(self.context, '@@manage')+'#tab-1')
+        return
+
+    def getLocalRoles(self):
+        roles = ILocalRolesAssignable(self.context)
+        return roles()
+
+    def getUsers(self):
+        """Get a list of all users.
+        """
+        for key, val in grok.getSite()['users'].items():
+            url = self.url(val)
+            yield(dict(url=url, name=key, val=val))
+
+    @grok.action('Save')
+    def save(self, **data):
+        self.applyData(self.context, **data)
+        return
+
+    @grok.action('Cancel', validator=NullValidator)
+    def cancel(self, **data):
+        self.redirect(self.url(self.context))
+        return
+
+    @grok.action('Add subunit', validator=NullValidator)
+    def addSubunit(self, **data):
+        self.redirect(self.url(self.context, '@@add'))
+        return
+
+    @grok.action('Add local role', validator=NullValidator)
+    def addLocalRole(self, **data):
+        form = self.request.form
+        localrole = form['local_role']
+        user = form['user']
+        role_manager = IPrincipalRoleManager(self.context)
+        role_map = IPrincipalRoleMap(self.context)
+        role_manager.assignRoleToPrincipal(localrole, user)
+        self.redirect(self.url(self.context, u'@@manage')+'#tab-3')
+        return
+
 class UniversityPage(WAeUPDisplayFormPage):
     """ The main university page.
@@ -934,15 +1006,10 @@
         return 'Departments'
 
-class FacultyManageFormPage(WAeUPEditFormPage):
+class FacultyManageFormPage(ContainerManageFormPage):
     """Manage the basic properties of a `Faculty` instance.
     """
     grok.context(IFaculty)
-    grok.name('manage')
-    grok.require('waeup.manageUniversity')
     grok.template('facultymanagepage')
     pnav = 1
-    taboneactions = ['Save','Cancel']
-    tabtwoactions = ['Add department', 'Remove selected','Cancel']
-    tabthreeactions = ['Add local role', 'Remove local roles selected']
     subunits = 'Departments'
 
@@ -956,16 +1023,4 @@
     def title(self):
         return self.context.longtitle()
-
-    def getLocalRoles(self):
-        roles = ILocalRolesAssignable(self.context)
-        return roles()
-
-    def getUsers(self):
-        """Get a list of all users.
-        """
-        for key, val in grok.getSite()['users'].items():
-            url = self.url(val)
-            #import pdb; pdb.set_trace()
-            yield(dict(url=url, name=key, val=val))
 
     def update(self):
@@ -973,51 +1028,4 @@
         #warning.need()
         return super(FacultyManageFormPage, self).update()
-
-    @grok.action('Save')
-    def save(self, **data):
-        self.applyData(self.context, **data)
-        return
-
-    # ToDo: Show warning message before deletion
-    @grok.action('Remove selected')
-    def delDepartments(self, **data):
-        form = self.request.form
-        child_id = form['val_id']
-        if not isinstance(child_id, list):
-            child_id = [child_id]
-        deleted = []
-        for id in child_id:
-            try:
-                del self.context[id]
-                deleted.append(id)
-            except:
-                self.flash('Could not delete %s: %s: %s' % (
-                        id, sys.exc_info()[0], sys.exc_info()[1]))
-        if len(deleted):
-            self.flash('Successfully removed: %s' % ', '.join(deleted))
-        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
-        return
-
-    @grok.action('Add department', validator=NullValidator)
-    def addDepartment(self, **data):
-        self.redirect(self.url(self.context, '@@add'))
-        return
-
-    @grok.action('Cancel', validator=NullValidator)
-    def cancel(self, **data):
-        self.redirect(self.url(self.context))
-        return
-
-    @grok.action('Add local role', validator=NullValidator)
-    def addLocalRole(self, **data):
-        form = self.request.form
-        localrole = form['local_role']
-        user = form['user']
-        role_manager = IPrincipalRoleManager(self.context)
-        role_map = IPrincipalRoleMap(self.context)
-        #import pdb; pdb.set_trace()
-        role_manager.assignRoleToPrincipal(localrole, user)
-        self.redirect(self.url(self.context, u'@@manage')+'#tab-3')
-        return
 
 class DepartmentAddFormPage(WAeUPAddFormPage):
