~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/browser/potemplate.py

  • Committer: Benji York
  • Date: 2011-07-29 17:01:31 UTC
  • mto: This revision was merged to the branch mainline in revision 13567.
  • Revision ID: benji.york@canonical.com-20110729170131-6mv9de08e7itu3ei
Fix failing tests (and work less) by using the original query when not rendering a distroseries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
880
880
        self.user_is_logged_in = (self.user is not None)
881
881
 
882
882
    def iter_data(self):
 
883
        # If this is not a distroseries, then the query is much simpler.
 
884
        if not self.is_distroseries:
 
885
            potemplateset = getUtility(IPOTemplateSet)
 
886
            # The "shape" of the data returned by POTemplateSubset isn't quite
 
887
            # right so we have to run it through zip first.
 
888
            return zip(potemplateset.getSubset(
 
889
                productseries=self.productseries,
 
890
                distroseries=self.distroseries,
 
891
                ordered_by_names=True))
 
892
 
 
893
        # Otherwise we have to do more work, primarily for the "sharing"
 
894
        # column.
883
895
        OtherTemplate = ClassAlias(POTemplate)
884
896
        join = (self.context.getTemplatesCollection()
885
897
            .joinOuter(Packaging, And(
899
911
            .joinInner(SourcePackageName,
900
912
                SourcePackageName.id == POTemplate.sourcepackagenameID))
901
913
 
902
 
        # We query for SourcePackageName so it will be cached, so there is no
903
 
        # need to include it in the results.
904
914
        return join.select(POTemplate, Packaging, ProductSeries, Product,
905
915
            OtherTemplate, SourcePackageName)
906
916