← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wallyworld/launchpad/fix-translation-pages-numbers into lp:launchpad

 

Ian Booth has proposed merging lp:~wallyworld/launchpad/fix-translation-pages-numbers into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #778375 in Launchpad itself: "Product and ProductSeries translation pages numbers do not link anywhere"
  https://bugs.launchpad.net/launchpad/+bug/778375

For more details, see:
https://code.launchpad.net/~wallyworld/launchpad/fix-translation-pages-numbers/+merge/61193

Add links to the untranslated and unreviewed counts on the product/product series translation pages.

== Implementation ==

Add the necessary tales to the productseries-translations-languages.pt file. The bug report said this was a regression but I can't see anywhere in the bzr history where the links were ever available in this template. The links were however available on the series language index page (serieslanguage-index.pt) so perhaps there was some confusion there. In any case, this is nice functionality to have.

== Test ==

Extend the xx-productseries-translations.txt doc test.

== Lint ==

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/translations/stories/productseries/xx-productseries-translations.txt
  lib/lp/translations/templates/productseries-translations-languages.pt

./lib/lp/translations/stories/productseries/xx-productseries-translations.txt
      94: want exceeds 78 characters.
      95: want exceeds 78 characters.

-- 
https://code.launchpad.net/~wallyworld/launchpad/fix-translation-pages-numbers/+merge/61193
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wallyworld/launchpad/fix-translation-pages-numbers into lp:launchpad.
=== modified file 'lib/lp/translations/stories/productseries/xx-productseries-translations.txt'
--- lib/lp/translations/stories/productseries/xx-productseries-translations.txt	2010-12-02 12:01:32 +0000
+++ lib/lp/translations/stories/productseries/xx-productseries-translations.txt	2011-05-17 03:15:50 +0000
@@ -16,6 +16,14 @@
 
 Listing languages with translations is best checked with a helper method.
 
+    >>> def extract_link_info(container):
+    ...         link_tag = container.find('a')
+    ...         if link_tag:
+    ...             href = extract_link_from_tag(link_tag)
+    ...         else:
+    ...             href = ''
+    ...         return int(extract_text(container)), href
+
     >>> def print_language_stats(browser):
     ...     table = find_tag_by_id(browser.contents, 'languagestats')
     ...     if table is None:
@@ -27,10 +35,12 @@
     ...     for row in language_rows:
     ...         cols = row.findAll('td')
     ...         language = extract_text(cols[0])
-    ...         untranslated = extract_text(cols[2])
-    ...         unreviewed = extract_text(cols[3])
-    ...         print "%-25s %13d %13d" % (
-    ...             language, int(untranslated), int(unreviewed))
+    ...         untranslated = extract_link_info(cols[2])
+    ...         unreviewed = extract_link_info(cols[3])
+    ...         print "%-25s %13d %13d\n" % (
+    ...             language, untranslated[0], unreviewed[0])
+    ...         print "Untranslated link: %s\n" % untranslated[1]
+    ...         print "Unreviewed link: %s\n" % unreviewed[1]
 
 When there are no translatable templates, series is considered as not
 being set up for translation.
@@ -62,7 +72,8 @@
     To start translating your project...
 
 With one translatable template (with fake stats for 10 messages), a listing
-of existing translations is shown.
+of existing translations is shown. Since there is only one template, each row
+count links to the correctly filtered PO file pages.
 
     >>> login('foo.bar@xxxxxxxxxxxxx')
     >>> pot = factory.makePOTemplate(
@@ -80,6 +91,8 @@
     >>> print_language_stats(browser)
     Language                   Untranslated    Unreviewed
     Serbian                               6             5
+    Untranslated link: /frobnicator/trunk/+pots/template1/sr/+translate?show=untranslated
+    Unreviewed link: /frobnicator/trunk/+pots/template1/sr/+translate?show=new_suggestions
 
 Since there is only one template, language link directly to PO file
 pages.
@@ -98,12 +111,15 @@
     >>> removeSecurityProxy(pot).messagecount = 5
     >>> logout()
 
-Statistics add up for untranslated messages.
+Statistics add up for untranslated messages. With more than one template the
+aggregated row numbers do not link anywhere.
 
     >>> browser.open(frobnicator_trunk_url)
     >>> print_language_stats(browser)
     Language                   Untranslated    Unreviewed
     Serbian                              11             5
+    Untranslated link:
+    Unreviewed link:
 
 With more than one template, link points to a product series per-language
 translations page.

=== modified file 'lib/lp/translations/templates/productseries-translations-languages.pt'
--- lib/lp/translations/templates/productseries-translations-languages.pt	2010-12-02 11:01:43 +0000
+++ lib/lp/translations/templates/productseries-translations-languages.pt	2011-05-17 03:15:50 +0000
@@ -44,12 +44,33 @@
             <td>
               <span class="sortkey"
                     tal:content="language_stats/untranslatedCount">0</span>
-              <tal:value content="language_stats/untranslatedCount" />
+              <tal:set-render_as_link
+                  define="global render_as_link python: view.single_potemplate and language_stats.untranslatedCount"/>
+              <tal:no_link condition="not:render_as_link">
+                  <tal:value content="language_stats/untranslatedCount" />
+              </tal:no_link>
+              <tal:link condition="render_as_link">
+                <a tal:attributes="href string:${language_stats/pofile/fmt:url}/+translate?show=untranslated"
+                  tal:content="language_stats/untranslatedCount"
+                  >0
+                </a>
+              </tal:link>
              </td>
             <td>
               <span class="sortkey"
                     tal:content="language_stats/unreviewedCount">0</span>
-              <tal:value content="language_stats/unreviewedCount" />
+              <tal:set-render_as_link
+                  define="global render_as_link python: view.single_potemplate and language_stats.unreviewedCount"/>
+              <tal:no_link condition="not:render_as_link">
+                  <tal:value content="language_stats/unreviewedCount" />
+              </tal:no_link>
+              <tal:link condition="render_as_link">
+                <a tal:attributes="href
+                string:${language_stats/pofile/fmt:url}/+translate?show=new_suggestions"
+                  tal:content="language_stats/unreviewedCount"
+                  >0
+                </a>
+              </tal:link>
             </td>
             <td>
               <span class="sortkey"