~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Edit person location information
================================

A person's location is only editable by people who have launchpad.Edit on
the person, which is that person and admins.

    >>> login('test@canonical.com')
    >>> zzz = factory.makePerson(
    ...     name='zzz', time_zone='Africa/Maseru', email='zzz@foo.com',
    ...     latitude=None, longitude=None, password='test')
    >>> logout()

A user cannot set another user's location.

    >>> nopriv_browser = setupBrowser(auth="Basic no-priv@canonical.com:test")
    >>> nopriv_browser.open('http://launchpad.dev/~zzz/+editlocation')
    Traceback (most recent call last):
    ...
    Unauthorized:...

A user can set his own location:

    >>> self_browser = setupBrowser(auth="Basic zzz@foo.com:test")
    >>> self_browser.open('http://launchpad.dev/~zzz/+editlocation')
    >>> self_browser.getControl(name='field.location.latitude').value = (
    ...     '39.48')
    >>> self_browser.getControl(name='field.location.longitude').value = (
    ...     '-0.40')
    >>> self_browser.getControl(name='field.location.time_zone').value = [
    ...     'Europe/Madrid']
    >>> self_browser.getControl('Update').click()

    >>> login('zzz@foo.com')
    >>> zzz.latitude
    39.4...
    >>> zzz.longitude
    -0.4...
    >>> zzz.time_zone
    u'Europe/Madrid'
    >>> logout()

The user can change his location:

    >>> self_browser.open('http://launchpad.dev/~zzz/+editlocation')
    >>> self_browser.getControl(name='field.location.latitude').value
    '39.48'

And so can a Launchpad admin:

    >>> admin_browser.open('http://launchpad.dev/~zzz/+editlocation')
    >>> admin_browser.getControl(name='field.location.latitude').value
    '39.48'