Merge lp:~bac/launchpad/bug-483607 into lp:launchpad

Proposed by Brad Crittenden
Status: Merged
Approved by: Graham Binns
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~bac/launchpad/bug-483607
Merge into: lp:launchpad
Diff against target: 159 lines (+53/-21)
5 files modified
lib/lp/registry/browser/person.py (+4/-4)
lib/lp/registry/browser/tests/person-views.txt (+28/-2)
lib/lp/registry/stories/foaf/xx-person-home.txt (+9/-2)
lib/lp/registry/stories/location/personlocation.txt (+2/-3)
lib/lp/registry/templates/person-portlet-map.pt (+10/-10)
To merge this branch: bzr merge lp:~bac/launchpad/bug-483607
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+14925@code.launchpad.net

Commit message

Only show the editlocation link and map to the person whose page is being viewed.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

= Summary =

On a person index page for a person with no location data set the
editlocation map is still shown though it should not be.

== Proposed fix ==

Only show the editlocation map if the logged in user is the same as page
being viewed.

Also change it so that the location portlet is not shown at all if there
is no location data to display.

== Pre-implementation notes ==

None.

== Implementation details ==

As above.

== Tests ==

bin/test -vvm lp.registry -t person-views.txt -t xx-person-home.txt -t
personlocation.txt

== Demo and Q/A ==

As mark go to https://launchpad.dev/~bac and see no location data. Look
at other users and verify that the editlocation map is not shown and
that the location data only shows up if their location is set.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/registry/browser/tests/person-views.txt
  lib/lp/registry/templates/person-portlet-map.pt
  lib/lp/registry/stories/foaf/xx-person-home.txt
  lib/lp/registry/stories/location/personlocation.txt
  lib/lp/registry/browser/person.py

== Pylint notices ==

lib/lp/registry/browser/person.py
    117: [F0401] Unable to import 'lazr.delegates' (No module named
delegates)
    118: [F0401] Unable to import 'lazr.config' (No module named config)
    119: [F0401] Unable to import 'lazr.restful.interface' (No module
named restful)
    230: [F0401] Unable to import 'lazr.uri' (No module named uri)

Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/person.py'
2--- lib/lp/registry/browser/person.py 2009-11-17 02:56:38 +0000
3+++ lib/lp/registry/browser/person.py 2009-11-17 16:39:11 +0000
4@@ -3207,13 +3207,13 @@
5 """Should the map portlet be displayed?
6
7 The map portlet is displayed only if the person has no location
8- specified, or if the user has permission to view the person's
9- location.
10+ specified (latitude), or if the user has permission to view the
11+ person's location.
12 """
13- if self.context.location is None:
14+ if self.user == self.context:
15 return True
16 else:
17- return check_permission('launchpad.View', self.context.location)
18+ return self.has_visible_location
19
20
21 class TeamIndexView(PersonIndexView):
22
23=== modified file 'lib/lp/registry/browser/tests/person-views.txt'
24--- lib/lp/registry/browser/tests/person-views.txt 2009-10-09 21:01:34 +0000
25+++ lib/lp/registry/browser/tests/person-views.txt 2009-11-17 16:39:11 +0000
26@@ -226,7 +226,7 @@
27 AssertionError: Can't generate the map for a person who hasn't set
28 a visible location.
29
30-If the user set's his location, but does not make it visible, needs_gmap2
31+If the user sets his location, but does not make it visible, needs_gmap2
32 will still be False and the map_portlet_html property cannot be called.
33
34 >>> login_person(sample_person)
35@@ -271,6 +271,33 @@
36 <script type="text/javascript">
37 YUI().use('node', 'lp.mapping', function(Y) { ...
38
39+The map portlet is shown if the user has not set his location and is
40+viewing his own page.
41+
42+ >>> user = factory.makePerson()
43+ >>> user.latitude is None
44+ True
45+ >>> login_person(user)
46+ >>> person_view = create_initialized_view(
47+ ... user, '+index')
48+ >>> person_view.should_show_map_portlet
49+ True
50+
51+However another user will not be shown the portlet.
52+
53+ >>> login('foo.bar@canonical.com')
54+ >>> person_view = create_initialized_view(
55+ ... user, '+index')
56+ >>> person_view.should_show_map_portlet
57+ False
58+
59+If a user has a location set and it is visibible then the portlet is shown.
60+
61+ >>> person_view = create_initialized_view(
62+ ... sample_person, '+index')
63+ >>> person_view.should_show_map_portlet
64+ True
65+
66
67 == Things a person is working on ==
68
69@@ -802,4 +829,3 @@
70 >>> view = create_initialized_view(sample_person, "+index")
71 >>> view.should_show_ppa_section
72 False
73-
74
75=== modified file 'lib/lp/registry/stories/foaf/xx-person-home.txt'
76--- lib/lp/registry/stories/foaf/xx-person-home.txt 2009-09-16 17:56:17 +0000
77+++ lib/lp/registry/stories/foaf/xx-person-home.txt 2009-11-17 16:39:11 +0000
78@@ -167,11 +167,18 @@
79
80 The user's time zone is displayed next to their location details:
81
82- >>> browser.open('http://launchpad.dev/~name12')
83+ >>> browser.open('http://launchpad.dev/~kamion')
84 >>> print extract_text(
85 ... find_tag_by_id(browser.contents, 'portlet-map'))
86 Location
87- Time zone: Australia/Perth
88+ Time zone: Europe/London...
89+
90+If the user does not have location data set then the portlet will not
91+be shown.
92+
93+ >>> browser.open('http://launchpad.dev/~bac')
94+ >>> print extract_text(
95+ ... find_tag_by_id(browser.contents, 'portlet-map'))
96
97 Teams don't have a time zone field.
98
99
100=== modified file 'lib/lp/registry/stories/location/personlocation.txt'
101--- lib/lp/registry/stories/location/personlocation.txt 2009-11-15 01:05:49 +0000
102+++ lib/lp/registry/stories/location/personlocation.txt 2009-11-17 16:39:11 +0000
103@@ -9,13 +9,12 @@
104 ... latitude=None, longitude=None)
105 >>> logout()
106
107-Any person can see another person's time zone.
108+Any person can see another person's time zone if their is also
109+location data set, otherwise the location portlet does not show up.
110
111 >>> anon_browser.open('http://launchpad.dev/~zzz')
112 >>> print extract_text(
113 ... find_tag_by_id(anon_browser.contents, 'portlet-map'))
114- Location
115- Time zone: Africa/Maseru
116
117 If a person has a location, there is a little map portlet in their
118 profile page. We can't test all the google javascript, but we can make sure
119
120=== modified file 'lib/lp/registry/templates/person-portlet-map.pt'
121--- lib/lp/registry/templates/person-portlet-map.pt 2009-08-21 14:59:17 +0000
122+++ lib/lp/registry/templates/person-portlet-map.pt 2009-11-17 16:39:11 +0000
123@@ -7,14 +7,15 @@
124 <div class="portlet" id="portlet-map"
125 tal:define="overview_menu context/menu:overview">
126
127- <h2>Location</h2>
128-
129- <div tal:condition="context/time_zone">
130- <strong>Time zone:</strong>
131- <span tal:replace="context/time_zone">UTC</span>
132- </div>
133-
134 <tal:show-map condition="view/should_show_map_portlet">
135+
136+ <h2>Location</h2>
137+
138+ <div tal:condition="context/time_zone">
139+ <strong>Time zone:</strong>
140+ <span tal:replace="context/time_zone">UTC</span>
141+ </div>
142+
143 <div style="width: 400px;" tal:condition="context/latitude">
144 <div id="person_map_actions"
145 style="position:relative; z-index: 9999;
146@@ -29,12 +30,11 @@
147 </div>
148
149 <tal:comment condition="nothing">
150- When a person's location is unset we can be sure any user will have
151- permission to set it, so we don't need to check that the link is enabled.
152+ Only the user can see the editlocation image and link.
153 </tal:comment>
154 <a tal:condition="not: context/latitude"
155 tal:attributes="href overview_menu/editlocation/target"
156- ><img src="/+icing/portlet-map-unknown.png" />
157+ ><img src="/+icing/portlet-map-unknown.png" />
158 </a>
159 </tal:show-map>
160