Code review comment for lp:~henninge/launchpad/bug-461756

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

= Bug 461756 =

The template ordering on a productseries or distroseries +templates page
seemed to be rather arbitrary. In reality, they were ordered by database
ids, which is not very useful if you want to find a specific template on
the page.

This ordering is taken from the POTemplateSubset ordering where the
template are retrieved from the database.

== Proposed fix ==

Add an optional ordering flag to POTemplateSubset to apply an ordering
by names to the query. The view code can then set that flag.

Ordering will be by POTemplate.name for a productseries and by
(SourcePackageName.name, POTemplate.name) for a distroseries.

== Implementation details ==

The flag 'ordered_by_names' defaults to 'False' to retain the old
behaviour on which other code (and tests) might depend.

== Tests ==

bin/test -vvct distroseries-templates -t productseries-templates

== Demo and Q/A ==

(rev 8619 on staging or rev 9804 on edge for bug 461818 to be fixed.)

Go to this url and verify that the templates are listed alphabetically
by the names of the source packages and the names of the templates.
https://translations.staging.launchpad.net/ubuntu/karmic/+templates

Here is one for a product, should be ordered by the names of the templates:
https://translations.staging.launchpad.net/ocportal/4.2.0/+templates

Note that the latter appears sorted, even without this fix, but that is
not true. Some templates are out of order. They were probably imported
in alphabetical order.

= 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/translations/interfaces/potemplate.py
  lib/lp/translations/browser/distroseries.py
  lib/lp/translations/stories/productseries/xx-productseries-templates.txt
  lib/lp/translations/browser/productseries.py
  lib/lp/translations/model/potemplate.py
  lib/lp/translations/stories/distroseries/xx-distroseries-templates.txt

== Pylint notices ==

lib/lp/translations/interfaces/potemplate.py
    9: [F0401] Unable to import 'lazr.enum' (No module named enum)

« Back to merge proposal