    Filtering of contacts in contact listing views
    ==============================================

        >>> browser = Browser('manager', 'schooltool')
        >>> from schooltool.app.browser.ftests import setup
        >>> setup.setUpBasicSchool()
        >>> browser.getLink('Manage').click()

    Rename the manager.

        >>> browser.getLink('Persons').click()
        >>> browser.getLink('Manager').click()
        >>> browser.getLink('Edit').click()
        >>> browser.getControl('First name').value = "Pedro"
        >>> browser.getControl('Middle name').value = "José Martínez"
        >>> browser.getControl('Last name').value = "Pérez"
        >>> browser.getControl('Gender').value = ['male']
        >>> browser.getControl('Apply').click()

    Let's add a bunch of contacts:

        >>> from schooltool.contact.browser.ftests import addContact
        >>> for i in range(20):
        ...     addContact("Logan %s" % i, "Brown %s" % i, "Street %s" % i)

    They should be visible in the contact list now:

        >>> browser.getLink('Manage').click()
        >>> browser.getLink('Contacts').click()
        >>> browser.printQuery("id('content-body')/form/table/tbody//tr/td[2]/a")
Brown 0 Brown 1 Brown 10 Brown 11 Brown 12 Brown 13 Brown 14 Brown 15 Brown 16 Brown 17 Brown 18 Brown 19 Brown 2 Brown 3 Brown 4 Brown 5 Brown 6 Brown 7 Brown 8 Brown 9 PÃ©rez
    Let's filter out all the contacts whose names contain "Logan 1":

        >>> browser.getControl(name='SEARCH_FIRST_NAME').value = "Logan 1"
        >>> browser.getControl('Find Now').click()

    Only persons that match are in the list now:

        >>> browser.printQuery("id('content-body')/form/table/tbody//tr/td[2]/a")
Brown 1 Brown 10 Brown 11 Brown 12 Brown 13 Brown 14 Brown 15 Brown 16 Brown 17 Brown 18 Brown 19
    We can filter by last name too:

        >>> browser.getControl(name='SEARCH_LAST_NAME').value = "Brown 19"
        >>> browser.getControl('Find Now').click()
        >>> browser.printQuery("id('content-body')/form/table/tbody//tr/td[2]/a")
Brown 19 The same search form has appeared in the contact management page, but the LAST_NAME input field should contain the last name of the user in it by default: >>> browser.getLink('Home').click() >>> browser.getLink('Contacts').click() >>> analyze.printQuery("//div[@class='content-nav']/a", ... browser.contents) View Edit View Person Manage Contacts
        >>> browser.getLink('Manage Contacts').click()
        >>> analyze.printQuery("id('filter_widget')",
        ...                    browser.contents)

First name

Last name

This is because most of the time contact person for a student is his relative.