checklist employee module
=========================

Add a checklist:

    >>> self.setRoles(['Manager'])
    >>> from Products.CMFPlone.utils import _createObjectByType
    >>> portal.portal_types['Checklist'].global_allow = True
    >>> ignored = portal.invokeFactory('Checklist', id='checklist')
    >>> portal['checklist']
    <Checklist at /plone/checklist>

Call the view:

    >>> view = portal.restrictedTraverse('checklist/@@checklistview')
    >>> view
    <Products.Five.metaclass.ChecklistView object at ...>

Grab the tool:

    >>> from Products.CMFCore.utils import getToolByName
    >>> tool = getToolByName(portal, 'portal_checklist')
    >>> tool
    <ChecklistTool at /plone/portal_checklist>

The initial list of default items is empty, so a newly created
checklist item also has an empty list.

    >>> tool.getDefaultItems()
    ()
    >>> tool.getDefaultManagerItems()
    ()
    >>> portal.checklist.getAllItems()
    ()
    >>> portal.checklist.getAllManagerItems()
    ()
    >>> portal.checklist.remainingItems()
    ()
    >>> portal.checklist.remainingManagerItems()
    ()

If we add an item to the tool and create a new item, it ought to have
that checklist item, too.

    >>> tool.addItem('Read harry potter, book 7')
    >>> tool.getDefaultItems()
    ('Read harry potter, book 7',)
    >>> _createObjectByType('Checklist', portal, 'checklist2')
    <Checklist at /plone/checklist2>
    >>> portal.checklist2.getAllItems()
    ('Read harry potter, book 7',)
    >>> portal.checklist2.remainingItems()
    ('Read harry potter, book 7',)

Same holds for manager items in the list.

    >>> tool.addManagerItem('See harry potter movie 5')
    >>> tool.getDefaultManagerItems()
    ('See harry potter movie 5',)
    >>> _createObjectByType('Checklist', portal, 'checklist3')
    <Checklist at /plone/checklist3>
    >>> portal.checklist3.getAllManagerItems()
    ('See harry potter movie 5',)
    >>> portal.checklist3.remainingManagerItems()
    ('See harry potter movie 5',)

The original checklist item should still be 'empty':

    >>> portal.checklist.getAllItems()
    ()

If we add another item, but tell the add method to add it to all
existing checklists, too, we ought to see it appear on existing items,
too.

    >>> tool.addItem('Drink butterbeer', addToAll=True)
    >>> tool.getDefaultItems()
    ('Read harry potter, book 7', 'Drink butterbeer')
    >>> _createObjectByType('Checklist', portal, 'checklist4')
    <Checklist at /plone/checklist4>
    >>> portal.checklist4.getAllItems()
    ('Read harry potter, book 7', 'Drink butterbeer')
    >>> portal.checklist2.getAllItems()
    ('Read harry potter, book 7', 'Drink butterbeer')
    >>> portal.checklist.getAllItems()
    ('Drink butterbeer',)

Adding the same item another time doesn't really add it, both in the
tool and in the content types.

    >>> tool.addItem('Drink butterbeer', addToAll=True)
    >>> tool.getDefaultItems()
    ('Read harry potter, book 7', 'Drink butterbeer')
    >>> portal.checklist.getAllItems()
    ('Drink butterbeer',)
    >>> portal.checklist.addItem('Drink butterbeer')
    >>> portal.checklist.getAllItems()
    ('Drink butterbeer',)

Permissions
-----------

The normal employeemodule workflow applies, so only HrmManagers and
WorklocationManagers can edit. There is one extra restriction: the
manager checklist items can only be edited by the HrmManager, not by
the WorklocationManager.

For easy testing, we'll give the WorklocationManager that role
globally. It doesn't matter for the tests results, but it is important
to note that that's not something that's intended for normal use.

    >>> self.portal.portal_membership.addMember('admin', 'secret', ['Manager', 'HrmManager'], [])
    >>> self.portal.portal_membership.addMember('wlemployee', 'secret', ['WorklocationEmployee'], [])
    >>> self.portal.portal_membership.addMember('wlmanager', 'secret', ['WorklocationManager'], [])

The admin can edit:

    >>> self.setRoles([])
    >>> self.login('admin')
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedItems')
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedManagerItems')

The worklocation manager can only edit the normal items:

    >>> self.login('wlmanager')
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedItems')
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedManagerItems')
    Traceback (most recent call last):
    ...
    Unauthorized: You are not allowed to access 'setCheckedManagerItems' in this context

The worklocation employee cannot edit:

    >>> self.login('wlemployee')
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedItems')
    Traceback (most recent call last):
    ...
    Unauthorized: You are not allowed to access 'setCheckedItems' in this context
    >>> method = self.portal.restrictedTraverse('checklist/setCheckedManagerItems')
    Traceback (most recent call last):
    ...
    Unauthorized: You are not allowed to access 'setCheckedManagerItems' in this context


