Index: waeup/branches/ulif-rewrite/src/waeup/university/department.py
===================================================================
--- waeup/branches/ulif-rewrite/src/waeup/university/department.py	(revision 4498)
+++ waeup/branches/ulif-rewrite/src/waeup/university/department.py	(revision 4499)
@@ -6,9 +6,9 @@
 from zope.component.interfaces import IFactory
 from zope.interface import implementedBy
-from waeup.interfaces import IDepartment, ICourse
+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)
+                            Manage, AddCourse, AddCertificate)
 
 class Department(grok.Container):
@@ -175,2 +175,40 @@
                                     # 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.
