Overlayed calendars of deleted objects
======================================

Regression test for http://issues.schooltool.org/issue369

When you delete a person or a group or a resource, its calendar isn't
removed from overlay lists of other persons, causing problems later
on.


Setup
-----

    >>> manager_browser = Browser('manager', 'schooltool')

    >>> manager_browser.open('http://localhost/access_control.html')
    >>> manager_browser.getControl('Everyone can view resource calendars').click()
    >>> manager_browser.getControl('Apply').click()

We will need a user and a resource:

    >>> from schooltool.app.browser.ftests.setup import addResource
    >>> from schooltool.basicperson.browser.ftests.setup import addPerson
    >>> addPerson('Stephan', 'Richter', 'srichter', 'foobar')
    >>> addResource('Pig')

Let's log in as the new user:

    >>> srichter_browser = Browser('srichter', 'foobar')

Let's add the resources calendar to his calendar overlays:

    >>> srichter_browser.open('http://localhost/persons/srichter/calendar')
    >>> srichter_browser.getControl('More...').click()

    >>> srichter_browser.getControl('Pig').selected = True
    >>> srichter_browser.getControl('Apply').click()

Test
----

We just added Pig to Stephan's overlays:

    >>> srichter_browser.open('http://localhost/persons/srichter/calendar')
    >>> 'http://localhost/resources/pig/calendar' in srichter_browser.contents
    True

If we delete the resource from the database:

    >>> manager_browser.open('http://localhost/resources/@@index.html?SEARCH_TYPE=resource|Resource')
    >>> manager_browser.getControl(name='delete.pig').value = True
    >>> manager_browser.getControl('Delete').click()
    >>> manager_browser.getControl('Confirm').click()

It should disappear from the overlay list.

    >>> srichter_browser.open('http://localhost/persons/srichter/calendar')
    >>> 'http://localhost/resources/pig/calendar' in srichter_browser.contents
    False

User should still be capable of modifying his overlay list:

    >>> srichter_browser.getControl(name="overlay:list").value = []
    >>> srichter_browser.getControl('Apply').click()
