Group-aware add views
=====================

A manager logs in

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

    >>> from schooltool.app.browser.ftests import setup
    >>> setup.setUpBasicSchool()

Let's change some of the default demographics fields to be group-specific:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Demographics').click()
    >>> manager.getLink('ethnicity').click()
    >>> manager.getLink('Edit').click()
    >>> manager.getControl(name='form.widgets.limit_keys:list').value = ['students']
    >>> manager.getControl('Apply').click()

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Demographics').click()
    >>> manager.getLink('language').click()
    >>> manager.getLink('Edit').click()
    >>> manager.getControl(name='form.widgets.limit_keys:list').value = ['teachers']
    >>> manager.getControl('Apply').click()

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Demographics').click()
    >>> manager.getLink('citizenship').click()
    >>> manager.getLink('Edit').click()
    >>> manager.getControl(name='form.widgets.limit_keys:list').value = ['administrators']
    >>> manager.getControl('Apply').click()

Adding a student will have only student demos:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Add Student').click()
    >>> manager.printQuery('//fieldset[@id="demo-data"]/div[@class="row"]/div[@class="label"]//span/text()')
    ID
    Ethnicity
    Place of birth

    >>> manager.getControl('First name').value = "John"
    >>> manager.getControl('Last name').value = "Petterson"
    >>> manager.getControl('Gender').value = ['male']
    >>> manager.getControl('Birth date').value = '1980-01-01'
    >>> manager.getControl('Username').value = "john"
    >>> manager.getControl('Password').value = "pwd"
    >>> manager.getControl('Confirm password').value = "pwd"

    >>> manager.getControl('ID').value = "001122"
    >>> manager.getControl('Ethnicity').displayValue = ['Black or African American']
    >>> manager.getControl('Place of birth').value = "South Hampton"
    >>> manager.getControl('Add').click()

    >>> manager.printQuery('//span[@id="form-widgets-ID"]/text()')
    001122
    >>> manager.printQuery('//span[@id="form-widgets-ethnicity"]/span/text()')
    Black or African American
    >>> manager.printQuery('//span[@id="form-widgets-placeofbirth"]/text()')
    South Hampton

Adding a teacher will have only teacher demos:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Add Teacher').click()
    >>> manager.printQuery('//fieldset[@id="demo-data"]/div[@class="row"]/div[@class="label"]//span/text()')
    ID
    Language
    Place of birth

    >>> manager.getControl('First name').value = "Bob"
    >>> manager.getControl('Last name').value = "Hall"
    >>> manager.getControl('Gender').value = ['male']
    >>> manager.getControl('Birth date').value = '1980-01-01'
    >>> manager.getControl('Username').value = "bhall"
    >>> manager.getControl('Password').value = "pwd"
    >>> manager.getControl('Confirm password').value = "pwd"

    >>> manager.getControl('ID').value = "987654"
    >>> manager.getControl('Language').value = "French"
    >>> manager.getControl('Place of birth').value = "Boston"
    >>> manager.getControl('Add').click()

    >>> manager.printQuery('//span[@id="form-widgets-ID"]/text()')
    987654
    >>> manager.printQuery('//span[@id="form-widgets-language"]/text()')
    French
    >>> manager.printQuery('//span[@id="form-widgets-placeofbirth"]/text()')
    Boston

Adding an administrator will have only administrator demos:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Add Administrator').click()
    >>> manager.printQuery('//fieldset[@id="demo-data"]/div[@class="row"]/div[@class="label"]//span/text()')
    ID
    Place of birth
    Citizenship

    >>> manager.getControl('First name').value = "Jane"
    >>> manager.getControl('Last name').value = "Brown"
    >>> manager.getControl('Gender').value = ['male']
    >>> manager.getControl('Birth date').value = '1980-01-01'
    >>> manager.getControl('Username').value = "jbrown"
    >>> manager.getControl('Password').value = "pwd"
    >>> manager.getControl('Confirm password').value = "pwd"

    >>> manager.getControl('ID').value = "123456"
    >>> manager.getControl('Place of birth').value = "Miami"
    >>> manager.getControl('Citizenship').value = 'Spain'
    >>> manager.getControl('Add').click()

    >>> manager.printQuery('//span[@id="form-widgets-ID"]/text()')
    123456
    >>> manager.printQuery('//span[@id="form-widgets-placeofbirth"]/text()')
    Miami
    >>> manager.printQuery('//span[@id="form-widgets-citizenship"]/text()')
    Spain

Clicking Cancel will return to persons index:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Persons').click()
    >>> manager.getLink('Add Teacher').click()
    >>> manager.getControl('Cancel').click()
    >>> manager.url
    'http://localhost/persons'

