Index: /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py
===================================================================
--- /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py	(revision 4650)
+++ /waeup/branches/ulif-layout/src/waeup/browser/viewlets.py	(revision 4651)
@@ -98,2 +98,78 @@
     grok.view(FacultyContainerPage)
     grok.template('manageaction')
+
+
+#
+# Add actions...
+#
+class AddAction(grok.Viewlet):
+    """Base class for 'adding actions'.
+
+    AddActions are viewlets that render a button linked to an adding
+    page. To create such a button in one of your pages, follow the
+    following steps:
+
+    - Create a new class derived from AddAction. In this class:
+    
+    - Set a grok.context() for the context type of your page. So, if
+      your page sets grok.context(IMyFunnyType), do the same in the
+      viewlet class.
+
+    - Set the Page on which the button should appear using
+      grok.view(). So, if your page class is MyFunnyPage, do
+      grok.view(MyFunnyPage).
+
+    - Set the template to use to 'addaction'. This means to use the
+      'addaction.pt' template in the templates/ dir. Don't fiddle
+      around with this template file, as it is used also by other
+      viewlets.
+
+    - If you want only certain authorized users to see the button, use
+      grok.require(<Permission>). By default only people with
+      waeup.manageUniversity permission are able to see your new
+      button. Other users, however, will still see your page, only
+      without the button rendered.
+
+    - As one can define several buttons for a certain page, you can
+      influence the order of buttons by setting grok.order(<num>). The
+      lower the number, the more left the button will be displayed and
+      vice versa. Default is 4.
+      
+    - Set the page name as ``addview_name`` attribute. This means, if
+      the page, the button is linked to can be reached by calling
+      http://localhost:8080/<current_location>/@@addfoo, then you should set::
+
+        addview_name = 'addfoo'
+
+      By default the target page name 'add' is assumed. You should
+      have good reasons not to name your AddFormPage 'add'.
+
+    - Set the button text by setting the ``addlink_text``
+      attribute. If you set it to 'Add foobar', then on the page will
+      appear a button with a small 'add stuff' icon and the text 'Add
+      foobar'.
+    """
+    grok.viewletmanager(ActionBar)
+    grok.view(FacultyContainerPage)
+    grok.context(IFacultyContainer)
+    grok.order(4)
+    grok.template('addaction')
+    grok.require('waeup.manageUniversity')
+    grok.baseclass()
+
+    addview_name = 'add'
+    addlink_text = 'Add department'
+
+    def getTargetURL(self):
+        return '%s/@@%s' % (self.view.url(self.view.context), self.addview_name)
+
+class AddFacultiesAction(AddAction):
+    grok.context(IFacultyContainer)
+    grok.view(FacultyContainerPage)
+    grok.order(4)
+    grok.template('addaction')
+    grok.require('waeup.manageUniversity')
+
+    addview_name = 'add'
+    addlink_text = 'Add faculty'
+
