Index: waeup/branches/ulif-layout/src/waeup/university/faculty.py
===================================================================
--- waeup/branches/ulif-layout/src/waeup/university/faculty.py	(revision 4713)
+++ waeup/branches/ulif-layout/src/waeup/university/faculty.py	(revision 4714)
@@ -1,13 +1,13 @@
+"""Faculty components.
+"""
+
 import grok
-from zope.component.interfaces import Invalid, IFactory
-from zope.component import createObject
-from zope.exceptions import DuplicationError
+from zope.component.interfaces import IFactory
 from zope.interface import implementedBy
 from waeup.interfaces import IFaculty, IDepartment
-from waeup.viewlets import (MainArea, LeftSidebar, Index, FormWrapMixin,
-                            Manage, Add)
-from waeup.widgets.interfaces import ITableProvider
 
 class Faculty(grok.Container):
+    """A university faculty.
+    """
     grok.implements(IFaculty)
 
@@ -22,4 +22,6 @@
 
     def addDepartment(self, department):
+        """Add a department to the faculty.
+        """
         if not IDepartment.providedBy(department):
             raise TypeError('Faculties contain only IDepartment instances')
@@ -27,4 +29,6 @@
 
     def clear(self):
+        """Remove all departments from faculty.
+        """
         keys = self.keys()
         for key in keys:
@@ -32,4 +36,6 @@
 
     def getName(self, key):
+        """Get complete faculty name.
+        """
         if key in self.keys():
             dept = self[key]
@@ -52,119 +58,2 @@
     def getInterfaces(self):
         return implementedBy(Faculty)
-
-class DisplayForm(grok.DisplayForm):
-    grok.context(IFaculty)
-    form_fields = grok.AutoFields(IFaculty)
- 
-class Content(FormWrapMixin, grok.Viewlet):
-    """A viewlet that wraps the `AddFacultyForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IFaculty)
-    grok.view(Index)
-    grok.order(2)
-    formview_name = 'displayform' # The name of the formview we want
-                                  # to be rendered in this viewlet.
-    
-class DepartmentList(grok.Viewlet):
-    grok.viewletmanager(MainArea)
-    grok.context(IFaculty)
-    grok.view(Index)
-    grok.order(3)
-
-    def update(self):
-        self.table = ITableProvider(self.context).getTables(view=self.view)[0]
-        self.table.need()
-
-class ManageForm(grok.EditForm):
-    """Manage the basic properties of a `Faculty` instance.
-    """
-
-    form_fields = grok.AutoFields(IFaculty)
-
-    @property
-    def label(self):
-        # Set faculty name as form label
-        return self.form_fields['title'].field.get(self.context)
-    
-    @grok.action('Save')
-    def save(self, **data):
-        self.applyData(self.context, **data)
-        return
-    
-    @grok.action('Save and return')
-    def saveAndReturn(self, **data):
-        self.applyData(self.context, **data)
-        self.redirect(self.url(self.context))
-        return
-
-    @grok.action('Cancel')
-    def cancel(self, **data):
-        self.redirect(self.url(self.context))
-        return
-
-class ManageFaculty(FormWrapMixin, grok.Viewlet):
-    """A viewlet that renders the `ManageForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IFaculty)
-    grok.view(Manage)
-    grok.require('waeup.manageUniversity')
-    
-    formview_name = 'manageform' # The name of the formview we want to
-                                 # be rendered in this viewlet.
-
-class ManageLink(grok.Viewlet):
-    grok.viewletmanager(LeftSidebar)
-    grok.context(IFaculty)
-    grok.view(Index)
-    grok.order(5)
-    # This link is only displayed, if the user is allowed to use it!
-    grok.require('waeup.manageUniversity')
-    
-    def render(self):
-        return u'<div class="portlet"><a href="manage">Settings</a></div>'
-
-class AddDepartmentForm(grok.AddForm):
-    grok.context(IFaculty)
-    form_fields = grok.AutoFields(IDepartment)
-    label = 'Add a department'
-
-    @grok.action('Add department')
-    def addDepartment(self, **data):
-        department = createObject(u'waeup.Department')
-        self.applyData(department, **data)
-        try:
-            self.context.addDepartment(department)
-        except DuplicationError:
-            self.status = Invalid('The name chosen already exists '
-                                  'in the database')
-            return
-        self.redirect(self.url(self.context))
-
-        
-class AddDepartment(FormWrapMixin, grok.Viewlet):
-    """A viewlet that wraps the `AddDepartmentForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IFaculty)
-    grok.view(Add)
-    grok.require('waeup.manageUniversity')
-
-    formview_name = 'adddepartmentform' # The name of the formview we
-                                     # want to be rendered in this
-                                     # viewlet.
-
-class AddDepartmentLink(grok.Viewlet):
-    """A link in the left sidebar displaying 'Add department'
-    """
-    grok.viewletmanager(LeftSidebar)
-    grok.context(IFaculty)
-    grok.view(Index)
-    grok.order(5)
-    # This is so cool! This link is only displayed, when the user is
-    # allowed to use it!
-    grok.require('waeup.manageUniversity')
-    
-    def render(self):
-        return u'<div class="portlet"><a href="add">Add department</a></div>'
