Index: waeup/branches/ulif-layout/src/waeup/university/department.py
===================================================================
--- waeup/branches/ulif-layout/src/waeup/university/department.py	(revision 4720)
+++ waeup/branches/ulif-layout/src/waeup/university/department.py	(revision 4721)
@@ -1,17 +1,13 @@
 """University departments.
 """
-import copy
 import grok
 from zope.component import createObject
-from zope.component.interfaces import IFactory, Invalid
-from zope.exceptions import DuplicationError
+from zope.component.interfaces import IFactory
 from zope.interface import implementedBy
-from waeup.interfaces import IDepartment, ICourse, ICertificate
-from waeup.utils.helpers import getName
-from waeup.widgets.interfaces import ITableProvider
-from waeup.viewlets import (MainArea, LeftSidebar, Index, FormWrapMixin,
-                            Manage, AddCourse, AddCertificate)
+from waeup.interfaces import IDepartment
 
 class Department(grok.Container):
+    """A university department.
+    """
     grok.implements(IDepartment)
 
@@ -35,4 +31,7 @@
 
     def traverse(self, name):
+        """Deliver appropriate containers, if someone wants to go to courses
+        or departments.
+        """
         if name == 'courses':
             return self.courses
@@ -54,162 +53,5 @@
 
     def getInterfaces(self):
+        """Get interfaces of objects provided by this factory.
+        """
         return implementedBy(Department)
-
-
-class Content(grok.Viewlet):
-    """A viewlet that wraps the `AddDepartmentForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IDepartment)
-    grok.view(Index)
-    grok.require('waeup.manageUniversity')
-
-    def getName(self):
-        return getName(self.context)
-
-    def getParentName(self):
-        return getName(self.context.__parent__)
-
-class CourseList(grok.Viewlet):
-    grok.viewletmanager(MainArea)
-    grok.context(IDepartment)
-    grok.view(Index)
-    grok.order(3)
-
-    def update(self):
-        if 'delcourse' in self.request.form:
-            code = self.request.form['code']
-            del self.context.courses[code]
-        if 'delcert' in self.request.form:
-            code = self.request.form['code']
-            del self.context.certificates[code]
-        self.tables = ITableProvider(self.context).getTables(view=self.view)
-        self.coursetable = self.tables[0]
-        self.certificatetable = self.tables[1]
-        self.coursetable.need()
-
-
-class ManageForm(grok.EditForm):
-    """Manage the basic properties of a `Department` instance.
-    """
-
-    form_fields = grok.AutoFields(IDepartment)
-
-    @property
-    def label(self):
-        # Set department 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 ManageDepartment(FormWrapMixin, grok.Viewlet):
-    """A viewlet that renders the `ManageForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IDepartment)
-    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(IDepartment)
-    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 AddCourseForm(grok.AddForm):
-    grok.context(IDepartment)
-    # We need a deepcopy here, because otherwise also all other
-    # ICourse forms would be affected.
-    form_fields = copy.deepcopy(grok.AutoFields(ICourse))
-    form_fields.get('code').field.readonly = False
-    label = 'Add a course'
-
-    @grok.action('Add course')
-    def addCourse(self, **data):
-        course = createObject(u'waeup.Course')
-        self.applyData(course, **data)
-        try:
-            self.context.courses.addCourse(course)
-        except DuplicationError:
-            self.status = Invalid('The code chosen already exists '
-                                  'in the database')
-            return
-        self.redirect(self.url(self.context))
-
-    @grok.action('Cancel')
-    def cancel(self, **data):
-        self.redirect(self.url(self.context))
-        return
-
-        
-class AddCourse(FormWrapMixin, grok.Viewlet):
-    """A viewlet that wraps the `AddFacultyForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IDepartment)
-    grok.view(AddCourse)
-    grok.require('waeup.manageUniversity')
-
-    formview_name = 'addcourseform' # The name of the formview we
-                                    # want to be rendered in this
-                                    # viewlet.
-
-class AddCertificateForm(grok.AddForm):
-    grok.context(IDepartment)
-    # We need a deepcopy here, because otherwise also all other
-    # ICertificate forms would be affected.
-    form_fields = copy.deepcopy(grok.AutoFields(ICertificate))
-    form_fields.get('code').field.readonly = False
-    label = 'Add a certificate'
-
-    @grok.action('Add certificate')
-    def addCertificate(self, **data):
-        certificate = createObject(u'waeup.Certificate')
-        self.applyData(certificate, **data)
-        try:
-            self.context.certificates.addCertificate(certificate)
-        except DuplicationError:
-            self.status = Invalid('The name chosen already exists '
-                                  'in the database')
-            return
-        self.redirect(self.url(self.context))
-
-    @grok.action('Cancel')
-    def cancel(self, **data):
-        self.redirect(self.url(self.context))
-        return
-
-        
-class AddCertificate(FormWrapMixin, grok.Viewlet):
-    """A viewlet that wraps the `AddFacultyForm`.
-    """
-    grok.viewletmanager(MainArea)
-    grok.context(IDepartment)
-    grok.view(AddCertificate)
-    grok.require('waeup.manageUniversity')
-
-    formview_name = 'addcertificateform' # The name of the formview we
-                                         # want to be rendered in this
-                                         # viewlet.
