Merge lp:~henninge/launchpad/bug-467079 into lp:launchpad

Proposed by Henning Eggers
Status: Merged
Approved by: Henning Eggers
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~henninge/launchpad/bug-467079
Merge into: lp:launchpad
Diff against target: 152 lines (+27/-21)
4 files modified
lib/canonical/launchpad/icing/style-3-0.css (+6/-1)
lib/canonical/launchpad/templates/root-index.pt (+5/-5)
lib/lp/registry/browser/root.py (+1/-6)
lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt (+15/-9)
To merge this branch: bzr merge lp:~henninge/launchpad/bug-467079
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Michael Nelson (community) release-critical Abstain
Paul Hummer (community) code Approve
Review via email: mp+14264@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

= Bug 467079 =

The list of featured projects on the home page had a fixed length, an error which I introduced last cylcle although the old solution was bad too. It capped the first column at a fixed number and let the second grow to infinivity.

== Proposed fix ==

Dynamically calculate the length for each column according to the number of featured projects minus the top featured project. If the number is odd, make the first column one longer.

== Text ==

bin/test -vvct featuredprojects

== Demo/QA ==

Look at the homepage and see if Ubuntu and Zope are visible again ...

= 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/root.py
  lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt

== Pylint notices ==

lib/lp/registry/browser/root.py
    45: [F0401] Unable to import 'lazr.batchnavigator.z3batching' (No module named batchnavigator)
    509: [E1002, WindowedListBatch.__iter__] Use super on an old style class

Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hi Henning,

Thanks for fixing this! I'd prefer to see this land on edge next week - I can't classify it as a blocker, but I won't be offended if you get a second opinion :)

review: Abstain (release-critical)
Revision history for this message
Curtis Hovey (sinzui) wrote :
Download full text (3.9 KiB)

Hi Henning.

  review needs-fixing

Your view and CSS changes are good. The narrative of the story needs
revising. It is not a story. The narrative must explain what is seen and
happens from the users perspective. *We* care about contracts, and if
this test ware really about what *we* want to create, we could
instantiate the view, call render() and verify the markup much easier in
a view test.

I do not see how this test can pass. It checks for ids that do not exist
since the columns table-column properties were replace with simple CSS.

On Tue, 2009-11-17 at 17:23 +0000, Henning Eggers wrote:
> === modified file 'lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt'
> --- lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-09-21 14:48:17 +0000
> +++ lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-11-17 17:21:11 +0000
> @@ -24,21 +24,32 @@
> >>> print extract_text(featured.h2)
> Featured projects
>
> -We show the featured projects in our sample data, the "project of the day" is
> -"GNOME" and it is listed first:
> +We show the featured projects in our sample data. The "project of the day"
> +is "GNOME" and it is listed separately:

Any user can see the Launchpad featured projects. The project of the day
is listed separately.

> - >>> for link in featured.findAll('a'):
> - ... print extract_text(link)
> + >>> top_project = find_tag_by_id(featured, 'homepage-featured-top-title')
> + >>> print extract_text(top_project)
> GNOME
> +
> +These are the projects in the left column.

He see's content in a left column.

--but I cannot see how this will work because the template does not have
these ids, we let the stylesheet do the layout. There is a single list
that we need to test. If the layout is changed in the CSS, we do not
need to worry about the test breaking. This was one of the 3.0 UI
goals--no brittle tests that verifies markup. While this does not verify
the markup, it still feels like it is trying to force a two column
table.

> + >>> def print_column(column_id):
> + ... column = find_tag_by_id(featured, column_id)
> + ... for link in column.findAll('a'):
> + ... print extract_text(link)
> + >>> print_column('homepage-featured-left')
> Gnome Applets
> Bazaar
> Mozilla Firefox
> Gentoo
> +
> +These are the projects in the right column.

And content in a right column.

-- but I know that this test will fail

> + >>> print_column('homepage-featured-right')
> GNOME Terminal
> the Mozilla Project
> Mozilla Thunderbird
> Ubuntu
> - Browse all ... projects
>
> == Adding a featured project ==
>
> @@ -88,19 +99,27 @@
>
> >>> anon_browser.open('http://launchpad.dev/')
> >>> featured = find_tag_by_id(anon_browser.contents, 'homepage-featured')
> - >>> for link in featured.findAll('a'):
> - ... print extract_text(link)
> + >>> top_project = find_tag_by_id(featured, 'homepage-featured-top-title')
> + >>> print extract_text(top_project)
> Gentoo

I am not sure 'odd' is important here if we change the css, to be 3
column or 1 column it will not be odd. As...

Read more...

review: Needs Fixing
Revision history for this message
Henning Eggers (henninge) wrote :

Am 18.11.2009 01:18, Curtis Hovey schrieb:
> Review: Needs Fixing
> Hi Henning.
>
> review needs-fixing
>
> Your view and CSS changes are good.

Thanks, great to hear.

> The narrative of the story needs
> revising. It is not a story. The narrative must explain what is seen and
> happens from the users perspective. *We* care about contracts, and if
> this test ware really about what *we* want to create, we could
> instantiate the view, call render() and verify the markup much easier in
> a view test.

Ok, I reworded the test in that manner.

>
> I do not see how this test can pass. It checks for ids that do not exist
> since the columns table-column properties were replace with simple CSS.

I am very sorry but I knew that and I thought I had told you about it on
IRC yesterday. I just didn't have the time to update the test. This test
was still referring to the changes I had originally introduced. Again,
sorry for getting you confused...

I fixed the the test and also changed an id in the template to a class
because the id was used twice. I'll paste the incremental diff.

Cheers,
Henning

Revision history for this message
Henning Eggers (henninge) wrote :
Download full text (4.3 KiB)

=== modified file 'lib/canonical/launchpad/templates/root-index.pt'
--- lib/canonical/launchpad/templates/root-index.pt 2009-11-13 18:03:35 +0000
+++ lib/canonical/launchpad/templates/root-index.pt 2009-11-18 11:03:37 +0000
@@ -51,14 +51,14 @@
           margin-top: 1em;
           font-size: 161%;
           }
- .featured-project h3 {
+ .featured-project-top h3 {
           font-size: 131%;
           font-weight: bold;
           }
- .featured-project h3 img {
+ .featured-project-top h3 img {
           vertical-align: middle;
           }
- .featured-project p {
+ .featured-project-top p {
           margin-top: 0.5em;
           margin-bottom: 1em;
           border-bottom: 1px solid #888888;
@@ -226,7 +226,7 @@
             <div id="homepage-featured" class="homepage-portlet">
               <h2>Featured projects</h2>

- <div class="featured-project"
+ <div class="featured-project-top"
                    tal:define="topproject view/featured_projects_top"
                    tal:condition="topproject">
                 <h3>
@@ -241,7 +241,7 @@
               </div>

               <div class="two-column-list">
- <ul id="homepage-featured">
+ <ul class="featured-projects-list">
                   <li tal:repeat="project view/featured_projects">
                     <a tal:replace="structure project/fmt:link" />
                   </li>

=== modified file 'lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt'
--- lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-10-31 18:32:05 +0000
+++ lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-11-18 11:22:40 +0000
@@ -19,33 +19,26 @@
     >>> from lp.registry.browser.root import LaunchpadRootIndexView
     >>> LaunchpadRootIndexView._get_day_of_year = staticmethod(
     ... fake_get_day_of_year)
+
+Anonymous users will see the list of featured projects with links to the
+projects' pages in Launchpad. The "project of the day" is listed separately.
+
     >>> anon_browser.open('http://launchpad.dev/')
     >>> featured = find_tag_by_id(anon_browser.contents, 'homepage-featured')
     >>> print extract_text(featured.h2)
     Featured projects

-We show the featured projects in our sample data. The "project of the day"
-is "GNOME" and it is listed separately:
-
- >>> top_project = find_tag_by_id(featured, 'homepage-featured-top-title')
- >>> print extract_text(top_project)
+ >>> top_project = featured.find('', 'featured-project-top')
+ >>> print extract_text(top_project.h3)
     GNOME

-These are the projects in the left column.
-
- >>> def print_column(column_id):
- ... column = find_tag_by_id(featured, column_id)
- ... for link in column.findAll('a'):
- ... print extract_text(link)
- >>> print_column('homepage-featured-left')
+ >>> featured_list = featured.find('', 'featured-projects-list')
+ >>> for link in featured_list.findAll('a'):
+ ... print extract_text(link)
     Gnome Applets
     Bazaar
     Mozilla Firefox
     Gentoo
-
-These are the projects in the ri...

Read more...

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thanks for removing the limitiation

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/icing/style-3-0.css'
2--- lib/canonical/launchpad/icing/style-3-0.css 2009-11-13 17:49:40 +0000
3+++ lib/canonical/launchpad/icing/style-3-0.css 2009-11-18 11:26:12 +0000
4@@ -471,13 +471,18 @@
5 ol.subordinate {
6 margin-left: 4em;
7 }
8-.two-column-list li,
9 .two-column-list dl {
10 width: 48%;
11 float: left;
12 display: inline;
13 margin: 0 0.25em 0.75em 0;
14 }
15+.two-column-list li {
16+ width: 48%;
17+ float: left;
18+ display: inline;
19+ margin: 0 0.25em 0 0;
20+ }
21 .two-column-list:after {
22 content: ".";
23 display: block;
24
25=== modified file 'lib/canonical/launchpad/templates/root-index.pt'
26--- lib/canonical/launchpad/templates/root-index.pt 2009-11-13 18:03:35 +0000
27+++ lib/canonical/launchpad/templates/root-index.pt 2009-11-18 11:26:12 +0000
28@@ -51,14 +51,14 @@
29 margin-top: 1em;
30 font-size: 161%;
31 }
32- .featured-project h3 {
33+ .featured-project-top h3 {
34 font-size: 131%;
35 font-weight: bold;
36 }
37- .featured-project h3 img {
38+ .featured-project-top h3 img {
39 vertical-align: middle;
40 }
41- .featured-project p {
42+ .featured-project-top p {
43 margin-top: 0.5em;
44 margin-bottom: 1em;
45 border-bottom: 1px solid #888888;
46@@ -226,7 +226,7 @@
47 <div id="homepage-featured" class="homepage-portlet">
48 <h2>Featured projects</h2>
49
50- <div class="featured-project"
51+ <div class="featured-project-top"
52 tal:define="topproject view/featured_projects_top"
53 tal:condition="topproject">
54 <h3>
55@@ -241,7 +241,7 @@
56 </div>
57
58 <div class="two-column-list">
59- <ul id="homepage-featured">
60+ <ul class="featured-projects-list">
61 <li tal:repeat="project view/featured_projects">
62 <a tal:replace="structure project/fmt:link" />
63 </li>
64
65=== modified file 'lib/lp/registry/browser/root.py'
66--- lib/lp/registry/browser/root.py 2009-11-13 18:23:59 +0000
67+++ lib/lp/registry/browser/root.py 2009-11-18 11:26:12 +0000
68@@ -54,10 +54,6 @@
69 class LaunchpadRootIndexView(HasAnnouncementsView, LaunchpadView):
70 """An view for the default view of the LaunchpadRoot."""
71
72- # The homepage has two columns to hold featured projects. This
73- # determines the number of projects we display in each column.
74- FEATURED_PROJECT_ROWS = 11
75-
76 featured_projects = []
77 featured_projects_top = None
78
79@@ -75,9 +71,8 @@
80 super(LaunchpadRootIndexView, self).initialize()
81 # The maximum number of projects to be displayed as defined by the
82 # number of items plus one top featured project.
83- max_projects = self.FEATURED_PROJECT_ROWS + 1
84 self.featured_projects = list(
85- getUtility(IPillarNameSet).featured_projects)[:max_projects]
86+ getUtility(IPillarNameSet).featured_projects)
87 self._setFeaturedProjectsTop()
88
89 def _setFeaturedProjectsTop(self):
90
91=== modified file 'lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt'
92--- lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-09-21 14:48:17 +0000
93+++ lib/lp/registry/stories/launchpad-root/xx-featuredprojects.txt 2009-11-18 11:26:12 +0000
94@@ -19,17 +19,22 @@
95 >>> from lp.registry.browser.root import LaunchpadRootIndexView
96 >>> LaunchpadRootIndexView._get_day_of_year = staticmethod(
97 ... fake_get_day_of_year)
98+
99+Anonymous users will see the list of featured projects with links to the
100+projects' pages in Launchpad. The "project of the day" is listed separately.
101+
102 >>> anon_browser.open('http://launchpad.dev/')
103 >>> featured = find_tag_by_id(anon_browser.contents, 'homepage-featured')
104 >>> print extract_text(featured.h2)
105 Featured projects
106
107-We show the featured projects in our sample data, the "project of the day" is
108-"GNOME" and it is listed first:
109+ >>> top_project = featured.find('', 'featured-project-top')
110+ >>> print extract_text(top_project.h3)
111+ GNOME
112
113- >>> for link in featured.findAll('a'):
114+ >>> featured_list = featured.find('', 'featured-projects-list')
115+ >>> for link in featured_list.findAll('a'):
116 ... print extract_text(link)
117- GNOME
118 Gnome Applets
119 Bazaar
120 Mozilla Firefox
121@@ -38,7 +43,6 @@
122 the Mozilla Project
123 Mozilla Thunderbird
124 Ubuntu
125- Browse all ... projects
126
127 == Adding a featured project ==
128
129@@ -88,9 +92,13 @@
130
131 >>> anon_browser.open('http://launchpad.dev/')
132 >>> featured = find_tag_by_id(anon_browser.contents, 'homepage-featured')
133- >>> for link in featured.findAll('a'):
134+ >>> top_project = featured.find('', 'featured-project-top')
135+ >>> print extract_text(top_project.h3)
136+ Gentoo
137+
138+ >>> featured_list = featured.find('', 'featured-projects-list')
139+ >>> for link in featured_list.findAll('a'):
140 ... print extract_text(link)
141- Gentoo
142 Apache
143 Gnome Applets
144 Bazaar
145@@ -100,8 +108,6 @@
146 the Mozilla Project
147 Mozilla Thunderbird
148 Ubuntu
149- Browse all ... projects
150-
151
152 == Removing a project ==
153